orcle关键词

create table 'table'      创建表

foreign key (列名) references 'table'(列名)    关联表    表示此表是外键,主表

foreign key   外键

primary key   主键

check           检查

varchar2(n)      是一种可变长度类型,   参数代表总长度,输入几个字符占几个空间

char(n)     是一种固定长度类型,参数代表长度,  eg:char(10):存储的字符将占10个字节 哪怕你只输入一个字符 'a'

not  null

unique

commit     上传  运行以上的代码

drop table 'table'  彻底删除所有数据,连同表结构,不可回退,将自动提交事务

truncate table 'table' 删除表中记录,不删除表结构,不支持过滤条件,不能指定数据删除,不不支持回退

delete 'table' where ...   删除指定的表中指定的数据

create table 'table' back as   备份表格

insert into 'table' ..(列名)...value..(列值)..    插入数据

update sott.student set sname=..........   级联更新

select distinct  去重

alter table 'table'  Add   增加列

alter table 'table'   modify   修改列

alter table 'table'   drop column   删除列

alter table 'table'   rename column  修改列名

rownum     排序   根据输出的数据进行排序,只能从1开始,如果要查2-4名就不能用,

rowid        新增  修改  删除数据

initcap      将首字母大写,其他小写

upper       将所有字母大写

lower        将所有字母小写

lenght      核算总共有几个字符

to_date    将字符串转化成日期

eg:hiredate=to_date('1981-2-20','YYYY-MM-DD')

to_char    将日期转化为字符串

eg: to_char(hiredate,'YYYY-MM-DD')='1981-2-20'

多表联合查询

内连接:

  等值连接

select table1.column,table2.column

from table1, table2

where table1.column1=table2.column2  必须指定连接条件,如果不指定,查出的数据为两张表数据的乘积,当有3张或者N张表时,连接调节为N-1,两张表有相同的列名

  非等值连接:两张表没有相同的列名,但是表2的某一列或几列的值在表1某一列当中  过滤条件用 on

  自连接:.其中表中一列的值在另一列当中,在同一张表别名两张表   

eg:查出员工的领导名字

外链接:

  左外连接

  右外连接

  全外连接

猜你喜欢

转载自www.cnblogs.com/bin123/p/9274672.html