SQL应用及误区分析
上QQ阅读APP看书,第一时间看更新

t1

2.2 EMP

EMP保存了Oracle公司成立之初的14位员工的信息。表结构定义如表2-2所示。为了方便后续章节大数据量的测试,这里将EMPNO的长度由Oracle数据库安装时的4位调整为8位。

表2-2

EMP表在SQL Server数据库中的创建语句如图2-5所示。为了后续演示需要,给HIREDATE列增加默认值约束,默认值为当前日期。约束的概念在第9章会进行详细的介绍,此处如果不理解,可以先不深究。

图2-5

在SQL Server数据库中导入EMP表记录的脚本,如图2-6所示。

图2-6

在SQL Server数据库中导入EMP表记录完整脚本,如下所示。

    insert into emp values
   (7369, 'SMITH', 'CLERK',7902, '1980-12-17',800, null,20);
    insert into emp values
   (7499, 'ALLEN', 'SALESMAN',7698, '1981-2-20',1600,300,30);
    insert into emp values
   (7521, 'WARD', 'SALESMAN',7698, '1981-2-22',1250,500,30);
    insert into emp values
   (7566, 'JONES', 'MANAGER',7839, '1981-4-2',2975, NULL,20);
    insert into emp values
   (7654, 'MARTIN', 'SALESMAN',7698, '1981-9-28',1250,1400,30);
    insert into emp values
   (7698, 'BLAKE', 'MANAGER',7839, '1981-5-1',2850, NULL,30);
    insert into emp values
   (7782, 'CLARK', 'MANAGER',7839, '1981-9-6',2450, NULL,10);
    insert into emp values
   (7788, 'SCOTT', 'ANALYST',7566, '1987-4-19',3000, NULL,20);
    insert into emp values
   (7839, 'KING', 'PRESIDENT', NULL, '1981-11-17',5000, NULL,10);
    insert into emp values
   (7844, 'TURNER', 'SALESMAN',7698, '1980-9-8',1500,0,30);
    insert into emp values
   (7876, 'ADAMS', 'CLERK',7788, '1987-5-23',1100,0,20);
    insert into emp values
   (7900, 'JAMES', 'CLERK',7698, '1981-12-3',950, NULL,30);
    insert into emp values
   (7902, 'FORD', 'ANALYST',7566, '1981-12-3',3000, NULL,20);
    insert into emp values
   (7934, 'MILLER', 'CLERK',7782, '1982-1-23',1300, NULL,10);

EMP表在Oracle数据库中的创建语句如图2-7所示。

图2-7

在Oracle数据库中导入EMP表记录的脚本,如图2-8所示。

图2-8

在Oracle数据库中导入EMP表记录完整脚本,如下所示。

    insert into emp values
   (7369, 'SMITH', 'CLERK',7902, to_date('1980-12-17', 'yyyy-mm-dd'),800, null,20);
    insert into emp values
   (7499, 'ALLEN', 'SALESMAN',7698, to_date('1981-02-20', 'yyyy-mm-dd'),1600,300,30);
    insert into emp values
   (7521, 'WARD', 'SALESMAN',7698, to_date('1981-02-22', 'yyyy-mm-dd'),1250,500,30);
    insert into emp values
   (7566, 'JONES', 'MANAGER',7839, to_date('1981-04-02', 'yyyy-mm-dd'),2975, NULL,20);
    insert into emp values
   (7654, 'MARTIN', 'SALESMAN',7698, to_date('1981-09-28', 'yyyy-mm-dd'),1250,1400,30);
    insert into emp values
   (7698, 'BLAKE', 'MANAGER',7839, to_date('1981-05-01', 'yyyy-mm-dd'),2850, NULL,30);
    insert into emp values
   (7782, 'CLARK', 'MANAGER',7839, to_date('1981-06-09', 'yyyy-mm-dd'),2450, NULL,10);
    insert into emp values
   (7788, 'SCOTT', 'ANALYST',7566, to_date('1987-04-19', 'yyyy-mm-dd'),3000, NULL,20);
    insert into emp values
   (7839, 'KING', 'PRESIDENT', NULL, to_date('1981-11-17', 'yyyy-mm-dd'),5000, NULL,10);
    insert into emp values
   (7844, 'TURNER', 'SALESMAN',7698, to_date('1981-09-08', 'yyyy-mm-dd'),1500,0,30);
    insert into emp values
   (7876, 'ADAMS', 'CLERK',7788, to_date('1987-05-23', 'yyyy-mm-dd'),1100, NULL,20);
    insert into emp values
   (7900, 'JAMES', 'CLERK',7698, to_date('1981-12-03', 'yyyy-mm-dd'),950, NULL,30);
    insert into emp values
   (7902, 'FORD', 'ANALYST',7566, to_date('1981-12-03', 'yyyy-mm-dd'),3000, NULL,20);
    insert into emp values
   (7934, 'MILLER', 'CLERK',7782, to_date('1982-01-23', 'yyyy-mm-dd'),1300, NULL,10);