最常用的2個資料表emp dept
CREATE TABLE EMP (
EMPNO number(4) NOT NULL,
ENAME varchar2(10) NOT NULL,
JOB varchar2(9) NOT NULL,
MGR number(4),
HIREDATE DATE NOT NULL,
SAL number(7,2) NOT NULL,
COMM number(7,2),
DEPTNO number(2)
);
資料庫會報告一個ORA-01843的錯誤:
alter session set nls_date_language='american';
alter session set NLS_DATE_FORMAT='DD-MON-YY';
INSERT INTO emp VALUES ('7369', 'SMITH', 'CLERK', '7902', '17-DEC-90', '13750', '', '20');
INSERT INTO emp VALUES ('7499', 'ALLEN', 'SALESMAN', '7698', '20-FEB-89', '19000', '6400', '30');
INSERT INTO emp VALUES ('7521', 'WORD', 'SALESMAN', '7698', '22-FEB-93', '18500', '4250', '30');
INSERT INTO emp VALUES ('7566', 'JONES', 'MANAGER', '7839', '02-APR-89', '36850', '', '20');
INSERT INTO emp VALUES ('7654', 'MARTIN', 'SALESMAN', '7698', '28-SEP-97', '15675', '3500', '30');
INSERT INTO emp VALUES ('7698', 'BLAKE', 'MANAGER', '7839', '01-MAY-90', '24000', '', '30');
INSERT INTO emp VALUES ('7782', 'CLARK', 'MANAGER', '7839', '09-JUN-88', '27500', '', '10');
INSERT INTO emp VALUES ('7788', 'SCOTT', 'ANALYST', '7566', '19-APR-87', '19500', '', '20');
INSERT INTO emp VALUES ('7839', 'KING', 'PRESIDENT', '', '17-NOV-83', '82500', '', '10');
INSERT INTO emp VALUES ('7844', 'TURNER', 'SALESMAN', '7698', '08-SEP-92', '18500', '6250', '30');
INSERT INTO emp VALUES ('7876', 'ADAMS', 'CLERK', '7788', '23-MAY-96', '11900', '', '20');
INSERT INTO emp VALUES ('7900', 'JAMES', 'CLERK', '7698', '03-DEC-95', '12500', '', '30');
INSERT INTO emp VALUES ('7902', 'FORD', 'ANALYST', '7566', '03-DEC-91', '21500', '', '20');
INSERT INTO emp VALUES ('7934', 'MILLER', 'CLERK', '7782', '23-JAN-95', '13250', '', '10');
INSERT INTO emp VALUES ('3258', 'GREEN', 'SALESMAN', '4422', '24-JUL-95', '18500', '2750', '50');
INSERT INTO emp VALUES ('4422', 'STEVENS', 'MANAGER', '7839', '14-JAN-94 ', '24750', '', '50');
INSERT INTO emp VALUES ('6548', 'BARENS', 'CLERK', '4422', '16-JAN-95', '11950', '', '50');
INSERT INTO emp VALUES ('7500', 'CAMPBELL', 'ANALYST', '7566', '30-OCT-92 ', '24500', '0', '40');
CREATE TABLE DEPT (
DEPTNO number(2) NOT NULL,
DNAME char(10) ,
LOC char(10)
);
INSERT INTO dept VALUES ('10', 'ACCOUNTING', 'LONDON');
INSERT INTO dept VALUES ('30', 'SALES', 'LIVERPOOL');
INSERT INTO dept VALUES ('40', 'OPERATIONS', 'STAFFORD');
INSERT INTO dept VALUES ('50', 'MARKETING', 'LUTON');
INSERT INTO dept VALUES ('20', 'RESEARCH', 'PERSTON');
大批次生成資料:
INSERT INTO DEPT SELECT * FROM DEPT;
INSERT INTO EMP SELECT * FROM EMP;
oracle 11g 裡面的emp等sample表
執行以下語句即可:
$oracle_home/rdbms/admin/utlsampl.sql
EMPNO number(4) NOT NULL,
ENAME varchar2(10) NOT NULL,
JOB varchar2(9) NOT NULL,
MGR number(4),
HIREDATE DATE NOT NULL,
SAL number(7,2) NOT NULL,
COMM number(7,2),
DEPTNO number(2)
);
資料庫會報告一個ORA-01843的錯誤:
alter session set nls_date_language='american';
alter session set NLS_DATE_FORMAT='DD-MON-YY';
INSERT INTO emp VALUES ('7369', 'SMITH', 'CLERK', '7902', '17-DEC-90', '13750', '', '20');
INSERT INTO emp VALUES ('7499', 'ALLEN', 'SALESMAN', '7698', '20-FEB-89', '19000', '6400', '30');
INSERT INTO emp VALUES ('7521', 'WORD', 'SALESMAN', '7698', '22-FEB-93', '18500', '4250', '30');
INSERT INTO emp VALUES ('7566', 'JONES', 'MANAGER', '7839', '02-APR-89', '36850', '', '20');
INSERT INTO emp VALUES ('7654', 'MARTIN', 'SALESMAN', '7698', '28-SEP-97', '15675', '3500', '30');
INSERT INTO emp VALUES ('7698', 'BLAKE', 'MANAGER', '7839', '01-MAY-90', '24000', '', '30');
INSERT INTO emp VALUES ('7782', 'CLARK', 'MANAGER', '7839', '09-JUN-88', '27500', '', '10');
INSERT INTO emp VALUES ('7788', 'SCOTT', 'ANALYST', '7566', '19-APR-87', '19500', '', '20');
INSERT INTO emp VALUES ('7839', 'KING', 'PRESIDENT', '', '17-NOV-83', '82500', '', '10');
INSERT INTO emp VALUES ('7844', 'TURNER', 'SALESMAN', '7698', '08-SEP-92', '18500', '6250', '30');
INSERT INTO emp VALUES ('7876', 'ADAMS', 'CLERK', '7788', '23-MAY-96', '11900', '', '20');
INSERT INTO emp VALUES ('7900', 'JAMES', 'CLERK', '7698', '03-DEC-95', '12500', '', '30');
INSERT INTO emp VALUES ('7902', 'FORD', 'ANALYST', '7566', '03-DEC-91', '21500', '', '20');
INSERT INTO emp VALUES ('7934', 'MILLER', 'CLERK', '7782', '23-JAN-95', '13250', '', '10');
INSERT INTO emp VALUES ('3258', 'GREEN', 'SALESMAN', '4422', '24-JUL-95', '18500', '2750', '50');
INSERT INTO emp VALUES ('4422', 'STEVENS', 'MANAGER', '7839', '14-JAN-94 ', '24750', '', '50');
INSERT INTO emp VALUES ('6548', 'BARENS', 'CLERK', '4422', '16-JAN-95', '11950', '', '50');
INSERT INTO emp VALUES ('7500', 'CAMPBELL', 'ANALYST', '7566', '30-OCT-92 ', '24500', '0', '40');
CREATE TABLE DEPT (
DEPTNO number(2) NOT NULL,
DNAME char(10) ,
LOC char(10)
);
INSERT INTO dept VALUES ('10', 'ACCOUNTING', 'LONDON');
INSERT INTO dept VALUES ('30', 'SALES', 'LIVERPOOL');
INSERT INTO dept VALUES ('40', 'OPERATIONS', 'STAFFORD');
INSERT INTO dept VALUES ('50', 'MARKETING', 'LUTON');
INSERT INTO dept VALUES ('20', 'RESEARCH', 'PERSTON');
大批次生成資料:
INSERT INTO DEPT SELECT * FROM DEPT;
INSERT INTO EMP SELECT * FROM EMP;
oracle 11g 裡面的emp等sample表
執行以下語句即可:
$oracle_home/rdbms/admin/utlsampl.sql
點選(此處)摺疊或開啟
-
Rem Copyright (c) 1990, 2006, Oracle. All rights reserved.
-
Rem NAME
-
REM UTLSAMPL.SQL
-
Rem FUNCTION
-
Rem NOTES
-
Rem MODIFIED
-
Rem lburgess 04/02/06 - lowercase passwords
-
Rem menash 02/21/01 - remove unnecessary users for security reasons
-
Rem gwood 03/23/99 - make all dates Y2K compliant
-
Rem jbellemo 02/27/97 - dont connect as system
-
Rem akolk 08/06/96 - bug 368261: Adding date formats
-
Rem glumpkin 10/21/92 - Renamed from SQLBLD.SQL
-
Rem blinden 07/27/92 - Added primary and foreign keys to EMP and DEPT
-
Rem rlim 04/29/91 - change char to varchar2
-
Rem mmoore 04/08/91 - use unlimited tablespace priv
-
Rem pritto 04/04/91 - change SYSDATE to 13-JUL-87
-
Rem Mendels 12/07/90 - bug 30123;add to_date calls so language independent
-
Rem
-
rem
-
rem $Header: utlsampl.sql 02-apr-2006.21:13:01 lburgess Exp $ sqlbld.sql
-
rem
-
SET TERMOUT OFF
-
SET ECHO OFF
-
-
rem CONGDON Invoked in RDBMS at build time. 29-DEC-1988
-
rem OATES: Created: 16-Feb-83
-
-
DROP USER SCOTT CASCADE;
-
DROP USER ADAMS CASCADE;
-
DROP USER JONES CASCADE;
-
DROP USER CLARK CASCADE;
-
DROP USER BLAKE CASCADE;
-
GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO SCOTT IDENTIFIED BY tiger;
-
DROP PUBLIC SYNONYM PARTS;
-
-
CONNECT SCOTT/tiger
-
CREATE TABLE DEPT
-
(DEPTNO NUMBER(2) CONSTRAINT PK_DEPT PRIMARY KEY,
-
DNAME VARCHAR2(14) ,
-
LOC VARCHAR2(13) ) ;
-
CREATE TABLE EMP
-
(EMPNO NUMBER(4) CONSTRAINT PK_EMP PRIMARY KEY,
-
ENAME VARCHAR2(10),
-
JOB VARCHAR2(9),
-
MGR NUMBER(4),
-
HIREDATE DATE,
-
SAL NUMBER(7,2),
-
COMM NUMBER(7,2),
-
DEPTNO NUMBER(2) CONSTRAINT FK_DEPTNO REFERENCES DEPT);
-
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\',\'dd-mm-rr\')-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\', \'dd-mm-rr\')-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);
-
CREATE TABLE BONUS
-
(
-
ENAME VARCHAR2(10) ,
-
JOB VARCHAR2(9) ,
-
SAL NUMBER,
-
COMM NUMBER
-
) ;
-
CREATE TABLE SALGRADE
-
( GRADE NUMBER,
-
LOSAL NUMBER,
-
HISAL NUMBER );
-
INSERT INTO SALGRADE VALUES (1,700,1200);
-
INSERT INTO SALGRADE VALUES (2,1201,1400);
-
INSERT INTO SALGRADE VALUES (3,1401,2000);
-
INSERT INTO SALGRADE VALUES (4,2001,3000);
-
INSERT INTO SALGRADE VALUES (5,3001,9999);
-
COMMIT;
- EXIT
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1092353/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle之 手動建立 emp 表 與 dept 表Oracle
- 根據emp,dept,salgrade表進行的sql查詢語句(1)SQL
- excel表1和表2資料匹配 vlookup跨表兩個表格匹配Excel
- 最接受移民的國家(附原資料表)
- 前端常用6種資料加密方式的使用(最詳解)前端加密
- 5個常用的資料模型,讓資料分析更高效模型
- YII2 常用資料庫操作資料庫
- 分享一個MySQL資料庫表結構匯出word文件最方便的方法MySql資料庫
- 美國人最喜歡的飲料(附原資料表)
- 最喜歡咖啡的國家(附原資料表)
- 全球最強大的護照(附原資料表)
- 分散式資料庫拆表拆庫的常用策略分散式資料庫
- 操作sqlserver資料庫常用的三個方法SQLServer資料庫
- 值得白嫖的資料庫常用操作語句彙總(資料庫、資料表、資料操作)資料庫
- Oracle通過scott使用者中的emp練習單表操作Oracle
- 如何建立最簡單的 ABAP 資料庫表,以及編碼從資料庫表中讀取資料 (上)資料庫
- 2022年2月英國最暢銷車型銷量(附原資料表)
- 世界上最幸福的國家(附原資料表)
- 世界上最常用的語言(附原資料表)
- 10個最熱門的大資料技術大資料
- 4個常用的Python資料分析庫詳解!Python
- 修改SQL Server資料庫表的建立時間最簡單最直接有效的方法SQLServer資料庫
- DB2多分割槽資料庫的常用管理NWDB2資料庫
- 分享個常用的跨境電商資料分析平臺
- 盤點5個常用的Python資料科學庫!Python資料科學
- 我設計資料庫常用的幾個原則資料庫
- 04-2個常用的文字屬性
- 深入 TypeScript – 2( 幾個常用的小技巧)TypeScript
- (2) 電商資料庫表設計資料庫
- Python資料分析--Numpy常用函式介紹(2)Python函式
- 模擬資料傳輸常用方式PK,最安全高效的還得是它!
- 1-庫表檢視及常用資料型別資料型別
- 33個機器學習常用資料集機器學習
- 資料分析常用的 23 個 Pandas 程式碼,收好不謝
- Struts2框架自學之路——Action獲取表單資料的方式以及表單資料的封裝框架封裝
- 寫一個最簡陋的node框架(2)框架
- efcore 跨表查詢,實現一個介面內查詢兩個不同資料庫裡各自的表資料資料庫
- scala常用操作-去除字串最後一個字元字串字元
- SQL Server 批量生成資料庫內多個表的表結構SQLServer資料庫