oracle中scott用户的创建
时间:2021-07-01 10:21:17
帮助过:7人阅读
Rem Copyright (c)
1990 by Oracle Corporation
2 Rem NAME
3 REM UTLSAMPL.SQL
4 Rem FUNCTION
5 Rem NOTES
6 Rem MODIFIED
7 Rem gdudey
06/
28/
95 - Modified
for desktop seed database
8 Rem glumpkin
10/
21/
92 - Renamed
from SQLBLD.SQL
9 Rem blinden
07/
27/
92 -
Added primary and foreign keys to EMP and DEPT
10 Rem rlim
04/
29/
91 - change
char to varchar2
11 Rem mmoore
04/
08/
91 -
use unlimited tablespace priv
12 Rem pritto
04/
04/
91 - change SYSDATE to
13-JUL-
87
13 Rem Mendels
12/
07/
90 - bug
30123;add to_date calls so language independent
14 Rem
15 rem
16 rem $Header: utlsampl.sql
7020100.1 94/
09/
23 22:
14:
24 cli Generic<
base>
$ sqlbld.sql
17 rem
18 SET TERMOUT OFF
19 SET ECHO OFF
20
21 rem CONGDON Invoked
in RDBMS at build time.
29-DEC-
1988
22 rem OATES: Created:
16-Feb-
83
23
24 GRANT CONNECT,RESOURCE,UNLIMITED TABLESPACE TO SCOTT IDENTIFIED BY TIGER;
25 ALTER USER SCOTT DEFAULT TABLESPACE USERS;
26 ALTER USER SCOTT TEMPORARY TABLESPACE TEMP;
27 CONNECT SCOTT/
TIGER
28 DROP TABLE DEPT;
29 CREATE TABLE DEPT
30 (DEPTNO NUMBER(
2) CONSTRAINT PK_DEPT PRIMARY KEY,
31 DNAME VARCHAR2(
14) ,
32 LOC VARCHAR2(
13) ) ;
33 DROP TABLE EMP;
34 CREATE TABLE EMP
35 (EMPNO NUMBER(
4) CONSTRAINT PK_EMP PRIMARY KEY,
36 ENAME VARCHAR2(
10),
37 JOB VARCHAR2(
9),
38 MGR NUMBER(
4),
39 HIREDATE DATE,
40 SAL NUMBER(
7,
2),
41 COMM NUMBER(
7,
2),
42 DEPTNO NUMBER(
2) CONSTRAINT FK_DEPTNO REFERENCES DEPT);
43 INSERT INTO DEPT VALUES
44 (
10,
‘ACCOUNTING‘,
‘NEW YORK‘);
45 INSERT INTO DEPT VALUES (
20,
‘RESEARCH‘,
‘DALLAS‘);
46 INSERT INTO DEPT VALUES
47 (
30,
‘SALES‘,
‘CHICAGO‘);
48 INSERT INTO DEPT VALUES
49 (
40,
‘OPERATIONS‘,
‘BOSTON‘);
50 INSERT INTO EMP VALUES
51 (
7369,
‘SMITH‘,
‘CLERK‘,
7902,to_date(
‘17-12-1980‘,
‘dd-mm-yyyy‘),
800,NULL,
20);
52 INSERT INTO EMP VALUES
53 (
7499,
‘ALLEN‘,
‘SALESMAN‘,
7698,to_date(
‘20-2-1981‘,
‘dd-mm-yyyy‘),
1600,
300,
30);
54 INSERT INTO EMP VALUES
55 (
7521,
‘WARD‘,
‘SALESMAN‘,
7698,to_date(
‘22-2-1981‘,
‘dd-mm-yyyy‘),
1250,
500,
30);
56 INSERT INTO EMP VALUES
57 (
7566,
‘JONES‘,
‘MANAGER‘,
7839,to_date(
‘2-4-1981‘,
‘dd-mm-yyyy‘),
2975,NULL,
20);
58 INSERT INTO EMP VALUES
59 (
7654,
‘MARTIN‘,
‘SALESMAN‘,
7698,to_date(
‘28-9-1981‘,
‘dd-mm-yyyy‘),
1250,
1400,
30);
60 INSERT INTO EMP VALUES
61 (
7698,
‘BLAKE‘,
‘MANAGER‘,
7839,to_date(
‘1-5-1981‘,
‘dd-mm-yyyy‘),
2850,NULL,
30);
62 INSERT INTO EMP VALUES
63 (
7782,
‘CLARK‘,
‘MANAGER‘,
7839,to_date(
‘9-6-1981‘,
‘dd-mm-yyyy‘),
2450,NULL,
10);
64 INSERT INTO EMP VALUES
65 (
7788,
‘SCOTT‘,
‘ANALYST‘,
7566,to_date(
‘13-JUL-87‘)-
85,
3000,NULL,
20);
66 INSERT INTO EMP VALUES
67 (
7839,
‘KING‘,
‘PRESIDENT‘,NULL,to_date(
‘17-11-1981‘,
‘dd-mm-yyyy‘),
5000,NULL,
10);
68 INSERT INTO EMP VALUES
69 (
7844,
‘TURNER‘,
‘SALESMAN‘,
7698,to_date(
‘8-9-1981‘,
‘dd-mm-yyyy‘),
1500,
0,
30);
70 INSERT INTO EMP VALUES
71 (
7876,
‘ADAMS‘,
‘CLERK‘,
7788,to_date(
‘13-JUL-87‘)-
51,
1100,NULL,
20);
72 INSERT INTO EMP VALUES
73 (
7900,
‘JAMES‘,
‘CLERK‘,
7698,to_date(
‘3-12-1981‘,
‘dd-mm-yyyy‘),
950,NULL,
30);
74 INSERT INTO EMP VALUES
75 (
7902,
‘FORD‘,
‘ANALYST‘,
7566,to_date(
‘3-12-1981‘,
‘dd-mm-yyyy‘),
3000,NULL,
20);
76 INSERT INTO EMP VALUES
77 (
7934,
‘MILLER‘,
‘CLERK‘,
7782,to_date(
‘23-1-1982‘,
‘dd-mm-yyyy‘),
1300,NULL,
10);
78 DROP TABLE BONUS;
79 CREATE TABLE BONUS
80 (
81 ENAME VARCHAR2(
10) ,
82 JOB VARCHAR2(
9) ,
83 SAL NUMBER,
84 COMM NUMBER
85 ) ;
86 DROP TABLE SALGRADE;
87 CREATE TABLE SALGRADE
88 ( GRADE NUMBER,
89 LOSAL NUMBER,
90 HISAL NUMBER );
91 INSERT INTO SALGRADE VALUES (
1,
700,
1200);
92 INSERT INTO SALGRADE VALUES (
2,
1201,
1400);
93 INSERT INTO SALGRADE VALUES (
3,
1401,
2000);
94 INSERT INTO SALGRADE VALUES (
4,
2001,
3000);
95 INSERT INTO SALGRADE VALUES (
5,
3001,
9999);
96 COMMIT;
97
98 SET TERMOUT ON
99 SET ECHO ON
其次,将新建的txt文件保存为.sql文件,注意后缀名隐藏的话打开计算机----组织----文件夹选项----在隐藏已知文件的扩展名前面的√去掉,然后将.txt改成.sql
再次,将刚刚保存好的sql文件拷贝到linux服务器的 usr/local/oracle/product/rdbms/admin/目录下,可以看看创建时间
然后,使用命令:su - oracle -c ‘sqlplus / as sysdba‘切换到sqlplus命令行模式,执行以下语句
@$ORACLE_HOME/rdbms/admin/scott.sql
执行前:
执行:
执行后:
到此,scott用户的创建已经完成。
现在使用刚刚创建好的scott用户登录,但是发现密码不知道是什么,并不是tiger,然后使用sys用户对scott用户重新设置密码,如下:
最终顺利完成!
oracle中scott用户的创建
标签:原因 code 查找 客户机 use const 数据库 named ada