oracle 安装SCOTT/TIGER模式

前端之家收集整理的这篇文章主要介绍了oracle 安装SCOTT/TIGER模式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


  1. 安装SCOTT/TIGER模式

执行以下几个步骤即可:

1cd $ORACLE_HOME/sqlplus/demo

2、运行 demobld.sql

具体内容如下:

CREATE TABLE EMP

(EMPNO NUMBER(4) NOT NULL,

ENAME VARCHAR2(10),

JOB VARCHAR2(9),

MGR NUMBER(4),

HIREDATE DATE,

SAL NUMBER(7,2),

COMM NUMBER(7,

DEPTNO NUMBER(2)

);


INSERT INTO EMP VALUES (7369,'SMITH','CLERK',7902,

TO_DATE('17-DEC-1980','DD-MON-YYYY'),800,NULL,20);

INSERT INTO EMP VALUES (7499,'ALLEN','SALESMAN',7698,

TO_DATE('20-FEB-1981',1600,300,30);

INSERT INTO EMP VALUES (7521,'WARD',

TO_DATE('22-FEB-1981',1250,500,30);

INSERT INTO EMP VALUES (7566,'JONES','MANAGER',7839,

TO_DATE('2-APR-1981',2975,20);

INSERT INTO EMP VALUES (7654,'MARTIN',

TO_DATE('28-SEP-1981',1400,30);

INSERT INTO EMP VALUES (7698,'BLAKE',

TO_DATE('1-MAY-1981',2850,30);

INSERT INTO EMP VALUES (7782,'CLARK',

TO_DATE('9-JUN-1981',2450,10);

INSERT INTO EMP VALUES (7788,'SCOTT','ANALYST',7566,

TO_DATE('09-DEC-1982',3000,20);

INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',

TO_DATE('17-NOV-1981',5000,10);

INSERT INTO EMP VALUES (7844,'TURNER',

TO_DATE('8-SEP-1981',1500,30);

INSERT INTO EMP VALUES (7876,'ADAMS',7788,

TO_DATE('12-JAN-1983',1100,20);

INSERT INTO EMP VALUES (7900,'JAMES',

TO_DATE('3-DEC-1981',950,30);

INSERT INTO EMP VALUES (7902,'FORD',20);

INSERT INTO EMP VALUES (7934,'MILLER',7782,

TO_DATE('23-JAN-1982',1300,10);


CREATE TABLE DEPT

(DEPTNO NUMBER(2),

DNAME VARCHAR2(14),

LOC VARCHAR2(13)

);


INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK');

INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS');

INSERT INTO DEPT VALUES (30,'SALES','CHICAGO');

INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON ');


exit


其中demobld.sql 创建5个表。

执行完毕后,执行如下增加参考完整性的标准约束。

alter table emp add constraint emp_pk primary key(empno);

alter table dept add constraint dept_pk primary key(deptno);

alter table emp add constraint emp_fk_dept foreign key(deptno) references dept;

alter table emp add constraint emp_fk_emp foreign key(mgr) references emp;

@H_908_301@notes:可以将其安装到不同的账户。

  1. 删除演示模式安装



执行 demodrop.sql脚本即可。

原文链接:https://www.f2er.com/oracle/208876.html

猜你在找的Oracle相关文章