Chinaunix首页 | 论坛 | 博客
  • 博客访问: 96268
  • 博文数量: 59
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 385
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-29 15:12
文章分类

全部博文(59)

文章存档

2011年(1)

2009年(58)

我的朋友

分类: Oracle

2009-06-25 19:05:30

SQL语句总结
1:GROUP BY, HAVING, ORDER BY使用
select * from tab1 where id = 2 group by name having col > 5 order by ASC
 
2:join
   1> 两表正常关联inner join
      select A.id,B.name from A inner join on B where A.id = B.id;
   2> 使用左表关联右表left join
      select A.id,B.name from A left join on B where A.id = B.id;
   3> 使用右表关联左表right join
      select A.id,B.name from A right join on B where A.id = B.id;
 
3:alter
   alter table tab1 add col Integer not null default 1;
   alter table tab1 drop column col;
   alter table tab1 modify col Integer not null default 1;
 
4:escapse
   select * from tab1 where name like '%lu/_y%' escape '/';
 
5:rename tab1 to tab2;
 
6:Add user
   add user xxx identified by yyy default tablespace users;
   grant connect,resource to xxx;
 
7:select tab1_copy as select * from tab1;
 
8:create index IDX_id on tab1(id asc);
 
9:create or replace view tab1_view as select id, name from tab1 with check option;
阅读(436) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~