资源描述:
《oracle常用命令基础》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Oracle常用命令Oracle数据类型: Createtabletest1(namechar(10),sexchar(1)); Insertintotest1values(‘tomcatt北京’,’f’); Createtabletest2(namenchar(10),sexnchar(1)); Insertintotest2values(‘tomcatt北京’,’男’); 删除表droptable表名; Createtabletest3(namevarchar2(10),sexvarchar2(2)); Insertintotest3values(‘tomcat
2、t北京’,’f’);//插入值过大 Insertintotest3values(‘tomcat北京’,’f’); Createtabletest4(namevarchar2(10),agenumber(3),salarynumber(8,2)); Createtabletest5(namevarchar2(10),birthdate); Insertintotest5values(‘Tom’,’28-2月-08’); Insertintotest5values(‘Allen’,sysdate); DDL: 创建表 createtablescott.test6(
3、eidnumber(10), namevarchar2(20), hiredatedatedefaultsysdate, salarynumber(8,2)default0 ) 插入数据时若没有指定hiredate,salary的话则会取默认值 数据字典: Dba-所有方案包含的对象信息 All-用户可以访问的对象信息 User-用户方案的对象信息 Select*fromuser_tables; Select*fromall_tables; 约束: 域完整性约束:notnullcheck 实体完整性约束:uniqueprimarykey 参照完整性约
4、束:foreignkey 视图: Createorreplaceviewv1(eid,name,salary)asselectempno,ename,salfromempwheredeptno=30; 序列:sequence Createsequencemysequence1incrementby1startwith1nomaxvaluenocycle; Insertintotestvalues(mysequence1.nextval,’tom’); Createsequencestudent_sequencestartwith1incrementby1; Inse
5、rtintostudentvalues(student_sequence.nextval,’john’); 表间数据拷贝: Insertintodept1(id,name)selectdeptno,dnamefromdept; 实例(创建表ID字段自增): --createtabletest2(idchar(10)primarykeynotnull,namechar(10)); --createsequencetest2_sequenceincrementby1startwith1nomaxvaluenocycle; --insertintotest2values(t
6、est2_sequence.nextval,'john'); --insertintotest2values(test2_sequence.nextval,'allen'); --insertintotest2values(test2_sequence.nextval,'candy'); --insertintotest2values(test2_sequence.nextval,'aaaa'); --insertintotest2values(test2_sequence.nextval,'bbbbb'); --insertintotest2values(test2_
7、sequence.nextval,'cccccc'); --insertintotest2values(test2_sequence.nextval,'ddddd'); --insertintotest2values(test2_sequence.nextval,'eeeee'); --insertintotest2values(test2_sequence.nextval,'ggggg'); --insertintotest2values(test2_sequence.