--以system 登录 --先创建一个表空间 Create tablespace tbs_exercise Datafile 'D:\oracle\product\10.2.0\oradata\exercise\exercise.dbf' Size 50M AUTOEXTEND ON; CREATE User exercise identified by exercise default tablespace tbs_ exercise temporary tablespace temp; grant dba to exercise;
--以exercise用户身份登录创建下列表 create table DEPT ( DEPTNO NUMBER(2) not null, DNAME VARCHAR2(14), constraint PK_DEPT primary key (DEPTNO) ); begin Insert into DEPT values (1,'销售部门'); Insert into DEPT values (2,'研发部门'); commit; end;
create table EMP ( EMPNO NUMBER(4) not null, ENAME VARCHAR2(10), JOB VARCHAR2(20), HIREDATE DATE, SAL NUMBER(7,2), DEPTNO NUMBER(2), constraint PK_EMP primary key (EMPNO), constraint FK_DEPTNO foreign key (DEPTNO) references DEPT (DEPTNO) ); begin Insert into EMP values (1,'关公','java工程师',sysdate,'5000' ,2); Insert into EMP values (2,'张飞','java工程师',sysdate,'5000' ,2); Insert into EMP values (3,'赵云','.net工程师',sysdate,'5000',2); Insert into EMP values (4,'魏延' ,'java工程师',sysdate,'5000',2); commit; End;
-- Create sequence create sequence SEQ_EMP minvalue 1 maxvalue 999999999999999999999999999 start with 1 increment by 1 cache 20;