SCOTT/TIGER demonstration schema (demobld.sql)

10g及以上版本没有$ORACLE_HOME\sqlplus\demo,就更没有demobld.sql 但是有\u01\app\product\11.2.0\dbhome_1\RDBMS\ADMIN\scott.sql可以用来参考。

搭建环境我用自己建立的用户,然后执行编辑好的脚本。

1.用户。

创建表空间 create tablespace herbert datafile 'D:\oradata\herbert\herbert01.dbf' 2048m

创建用户create user herbert identified by herbert;

grant dba to herbert;

alter user herbert default tablespace herbert ;

2.表与约束。

修改日期格式。

alter session set nls_date_language='american';

建表插入数据

CREATE TABLE DEPT
       (DEPTNO NUMBER(2) ,
  DNAME VARCHAR2(14) ,
  LOC VARCHAR2(13) ) ;

CREATE TABLE EMP
       (EMPNO NUMBER(4) ,
  ENAME VARCHAR2(10),
  JOB VARCHAR2(9),
  MGR NUMBER(4),
  HIREDATE DATE,
  SAL NUMBER(7,2),
  COMM NUMBER(7,2),
  DEPTNO NUMBER(2) ;
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');
INSERT INTO EMP VALUES
(7369,'SMITH','CLERK',7902,to_date('17-12-1980','dd-mm-yyyy'),800,NULL,20);
INSERT INTO EMP VALUES
(7499,'ALLEN','SALESMAN',7698,to_date('20-2-1981','dd-mm-yyyy'),1600,300,30);
INSERT INTO EMP VALUES
(7521,'WARD','SALESMAN',7698,to_date('22-2-1981','dd-mm-yyyy'),1250,500,30);
INSERT INTO EMP VALUES
(7566,'JONES','MANAGER',7839,to_date('2-4-1981','dd-mm-yyyy'),2975,NULL,20);
INSERT INTO EMP VALUES
(7654,'MARTIN','SALESMAN',7698,to_date('28-9-1981','dd-mm-yyyy'),1250,1400,30);
INSERT INTO EMP VALUES
(7698,'BLAKE','MANAGER',7839,to_date('1-5-1981','dd-mm-yyyy'),2850,NULL,30);
INSERT INTO EMP VALUES
(7782,'CLARK','MANAGER',7839,to_date('9-6-1981','dd-mm-yyyy'),2450,NULL,10);
INSERT INTO EMP VALUES
(7788,'SCOTT','ANALYST',7566,to_date('13-JUL-87')-85,3000,NULL,20);
INSERT INTO EMP VALUES
(7839,'KING','PRESIDENT',NULL,to_date('17-11-1981','dd-mm-yyyy'),5000,NULL,10);
INSERT INTO EMP VALUES
(7844,'TURNER','SALESMAN',7698,to_date('8-9-1981','dd-mm-yyyy'),1500,0,30);
INSERT INTO EMP VALUES
(7876,'ADAMS','CLERK',7788,to_date('13-JUL-87')-51,1100,NULL,20);
INSERT INTO EMP VALUES
(7900,'JAMES','CLERK',7698,to_date('3-12-1981','dd-mm-yyyy'),950,NULL,30);
INSERT INTO EMP VALUES
(7902,'FORD','ANALYST',7566,to_date('3-12-1981','dd-mm-yyyy'),3000,NULL,20);
INSERT INTO EMP VALUES
(7934,'MILLER','CLERK',7782,to_date('23-1-1982','dd-mm-yyyy'),1300,NULL,10);
COMMIT;

修改约束

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;

注:

1.插入数据的客户端字符集是美国的,默认是中文的所以需要改一下,否则报错。

2.约束没弄好可以删掉重来:alter table emp drop constraint primary key cascade(cascade 表示删除与此主键关联的外键)




/* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20250404 (32-bit version) * Copyright (c) 2000 - 2025 Intel Corporation * * Disassembly of E:/EFI/OC/ACPI/DMAR.aml * * ACPI Data Table [DMAR] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue (in hex) */ [000h 0000 004h] Signature : "DMAR" [DMA Remapping Table] [004h 0004 004h] Table Length : 00000050 [008h 0008 001h] Revision : 01 [009h 0009 001h] Checksum : 40 [00Ah 0010 006h] Oem ID : "INTEL " [010h 0016 008h] Oem Table ID : "EDK2 " [018h 0024 004h] Oem Revision : 00000002 [01Ch 0028 004h] Asl Compiler ID : "INTL" [020h 0032 004h] Asl Compiler Revision : 20250404 [024h 0036 001h] Host Address Width : 26 [025h 0037 001h] Flags : 01 [026h 0038 00Ah] Reserved : 00 00 00 00 00 00 00 00 00 00 [030h 0048 002h] Subtable Type : 0000 [Hardware Unit Definition] [032h 0050 002h] Length : 0020 [034h 0052 001h] Flags : 01 [035h 0053 001h] Size (decoded below) : 00 Size (pages, log2) : 0 [036h 0054 002h] PCI Segment Number : 0000 [038h 0056 008h] Register Base Address : 0000000000D00000 [040h 0064 001h] Device Scope Type : 03 [IOAPIC Device] [041h 0065 001h] Entry Length : 08 [042h 0066 001h] Flags : 00 [043h 0067 001h] Reserved : 00 [044h 0068 001h] Enumeration ID : 02 [045h 0069 001h] PCI Bus Number : 00 [046h 0070 002h] PCI Path : 1E,07 [048h 0072 001h] Device Scope Type : 04 [Message-capable HPET Device] [049h 0073 001h] Entry Length : 08 [04Ah 0074 001h] Flags : 00 [04Bh 0075 001h] Reserved : 00 [04Ch 0076 001h] Enumeration ID : 00 [04Dh 0077 001h] PCI Bus Number : 00 [04Eh 0078 002h] PCI Path : 1E,06 Raw Table Data: Length 80 (0x50) 0000: 44 4D 41 52 50 00 00 00 01 40 49 4E 54 45 4C 20 // DMARP....^INTEL 0010: 45 44 4B 32 20 20 20 20 02 00 00 00 49 4E 54 4C // EDK2 ....INTL 0020: 04 04 25 20 26 01 00 00 00 00 00 00 00 00 00 00 // ..% &........... 0030: 00 00 20 00 01 00 00 00 00 00 D0 00 00 00 00 00 // .. ............. 0040: 03 08 00 00 02 00 1E 07 04 08 00 00 00 00 1E 06 // ................
最新发布
08-30
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值