1.表连接语法:join. . .on
eg:select ename,dname from emp join dept on(emp.dno=dept.dno);
2.分页:
eg:select ename,sal from
( select ename,sal,rownum r from
( select ename,sal from emp order by sal desc)
where r<=10)
where r>5 and r<=10;
3.建表语法:
create table tablename(
列名1 列类型 完整性约束,
列名2 列类型 完整性约束,
. . .
)
4.oracle中的数据类型:
varchar2(n)n的最大值为4k;
char(n);
number(p,s)整数或小数;
date日期类型;
long 最大值为2G;
5.select语句:
select. . .from. . .where. . .group by. . .having. . .order by. . .
6.insert语句:
insert . . . into table(列名1,列名2,列名3,· · ·)values(值1,值2,值3,· · ·);
7.update语句:
update table set 列名=‘ ’ where 条件;
8.delete语句:
delete. . .from table where 条件;
9.alter table 表名 add(列名 列类型 完整性约束);
alter table 表名 drop(列名 列类型 完整性约束);
alter table 表名 modify(类名 列类型 完整性约束);
alter table 表名 add constraint 约束名 约束内容 ;
alter table 表名 drop constraint 约束名;
10.创建索引:
create index 索引名 on 表名(字段1,字段2,字段. . .);
删除: drop index 索引名;
11.创建视图:
create view 视图名 as select();
删除视图:
drop view 视图名;
12.创建序列:
create sequence 序列名 start with 1 increment by 1;
删除序列:
drop sequence 序列名;
本文深入浅出地介绍了SQL的基本语法,包括表连接、分页、建表、数据类型、SELECT语句等,并详细解析了Oracle数据库中的数据类型如nvarchar2、char、number、date、long等。此外,文章还涵盖了SQL的插入、更新、删除操作,以及如何通过ALTER TABLE命令对表进行修改。同时,对于索引创建、视图创建、序列创建等数据库管理操作也进行了阐述。
2268

被折叠的 条评论
为什么被折叠?



