1.选择N行
select * from user_tables where rownum<=10;
select table_name from user_tables where rownum<=20 order by table_name; 升序
select table_name from user_tables where rownum<=20 order by table_name desc; 降序
2.计算总和:
select sum(column1) from table_name;
3.计算行数:
select count (*) from table_name where column_name = xxx;
4.排序:
select column1,avg(column2) from table_name group by column1 having avg(column2) > xxx;
select * from table_name1 where column1 like 'x%'
说明:like 必须和後面的'x%' 相呼应表示以 x为开头的字串。
区分大小写。
select * from table_name1 where column1 in ('xxx','yyy',..)
说明:in 後面接的是一个集合,表示column1 存在集合里面。
select * from table_name1 where column1 between xx and yy;
说明:between 表示 column1 的值介於 xx 和 yy 之间。
update table_name set column1='xxx' where conditoins;
delete from table_name where conditions;
a.如果是access数据库,则为:where mydate>#2000-01-01#
b. 如果是oracle数据库,则为:where mydate>cast('2000-01-01' as date) 或:where mydate>to_date('2000-01-01','yyyy-mm-dd') 在delphi中写成: thedate='2000-01-01'; query1.sql.add('select * from abc where mydate>cast('+''''+thedate+''''+' as date)');
推荐在oracle里面使用 如果比较日期时间型,则为: where mydatetime>to_date('2000-01-01 10:00:01','yyyy-mm-dd hh24:mi:ss')
阅读(630) | 评论(0) | 转发(0) |