Oracle常用命令的列舉
以下的文章主要是介紹Oracle常用命令,其中包括Oracle數(shù)據(jù)類型,視圖,以及實(shí)例的相關(guān)的介紹,如果你是Oracle常用命令方面的新手,相對(duì)Oracle常用命令的相關(guān)應(yīng)用方面有所了解的話,你就可以點(diǎn)擊以下的文章。
Oracle數(shù)據(jù)類型:
- Create table test1(name char(10),sex char(1));
 - Insert into test1 values(‘tomcatt北京’,’f’);
 - Create table test2(name nchar(10),sex nchar(1));
 - Insert into test2 values(‘tomcatt北京’,’男’);
 
刪除表 drop table 表名;
- Create table test3(name varchar2(10),sex varchar2(2));
 - Insert into test3 values(‘tomcatt北京’,’f’);
 
插入值過大
- Insert into test3 values(‘tomcat北京’,’f’);
 - Create table test4(name varchar2(10),age number(3),
 
salary number(8,2));- Create table test5(name varchar2(10),birth date);
 - Insert into test5 values(‘Tom’,’28-2月-08’);
 - Insert into test5 values(‘Allen’,sysdate);
 
DDL:
創(chuàng)建表
- create table scott.test6(
 - eid number(10),
 - name varchar2(20),
 - hiredate date default sysdate,
 - salary number(8,2) default 0
 - )
 
插入數(shù)據(jù)時(shí)若沒有指定hiredate,salary的話則會(huì)取默認(rèn)值
以下就是Oracle常用命令中Oracle數(shù)據(jù)字典的相關(guān)介紹:
Dba-所有方案包含的對(duì)象信息
All-用戶可以訪問的對(duì)象信息
User-用戶方案的對(duì)象信息
- Select * from user_tables;
 - Select * from all_tables;
 
約束:
域完整性約束:not null check
實(shí)體完整性約束:unique primary key
參照完整性約束:foreign key
視圖:
- Create or replace view v1(eid,name,salary) as select
 
empno,ename,sal from emp where deptno = 30;
序列:sequence
- Create sequence mysequence1 increment by 1 start
 
with 1 nomaxvalue nocycle;- Insert into test values(mysequence1.nextval,’tom’);
 - Create sequence student_sequence start with 1
 
increment by 1;- Insert into student values
 
(student_sequence.nextval,’john’);
表間數(shù)據(jù)拷貝:
- Insert into dept1(id,name) select deptno,
 
dname from dept;
實(shí)例(創(chuàng)建表 ID字段自增):
- create table test2(id char(10) primary key not null,
 
name char(10));- create sequence test2_sequence increment by 1 start
 
with 1 nomaxvalue nocycle;- insert into test2 values(test2_sequence.nextval,'john');
 - insert into test2 values(test2_sequence.nextval,'allen');
 - insert into test2 values(test2_sequence.nextval,'candy');
 - insert into test2 values(test2_sequence.nextval,'aaaa');
 - insert into test2 values(test2_sequence.nextval,'bbbbb');
 - insert into test2 values(test2_sequence.nextval,'cccccc');
 - insert into test2 values(test2_sequence.nextval,'ddddd');
 - insert into test2 values(test2_sequence.nextval,'eeeee');
 - insert into test2 values(test2_sequence.nextval,'ggggg');
 - insert into test2 values(test2_sequence.nextval,'jowwwwhn');
 - insert into test2 values(test2_sequence.nextval,'aaaadd');
 - insert into test2 values(test2_sequence.nextval,'ggghhh');
 - insert into test2 values(test2_sequence.nextval,'eeettt');
 - insert into test2 values(test2_sequence.nextval,'wwwttt');
 - select * from test2;
 
查看表結(jié)構(gòu)
EDITDATA 表名;
修改表字段:
Alter table 表名 modify(字段名 類型 約束);
alter table test modify (addd varchar2(10) null);
alter table 表名 add(字段名 類型 約束);
alter table test add(age varchar2(5));
上述的相關(guān)內(nèi)容就是對(duì)Oracle常用命令的描述,希望會(huì)給你帶來一些幫助在此方面。
【編輯推薦】















 
 
 

 
 
 
 