标签:原因 code 查找 客户机 use const 数据库 named ada
原创作品,转载请在文章开头显眼位置注明出处:https://www.cnblogs.com/sunshine5683/p/10046716.html
今天,接着上次的学习进度继续前进,在此过程中,使用scott用户登录时候显示scott用户不存在,于是进行scott用户的解锁操作
SQL> alter user scott account unlock;
alter user scott account unlock
*
第 1 行出现错误:
ORA-01918: 用户 ‘SCOTT‘ 不存在
由上面的过程可以很轻松的看出,scott用户不存在,然后进行scott用户的创建,网上有好多类似的创建方法,说在某个目录下面可以找到scott.sql文件,然后用相应的命令执行此操作便可以,但是在实际操作的过程中并没有发现该文件,可能是本人安装的数据库中本来就没有的原因,本人主要查找的目录有:
usr/local/oracle/product/rdbms/admin/ 目录,因为本人的数据库就在此目录下,并没有找到,那么就继续构造该文件
首先:在客户机上建立一个txt文件,然后在文件中输入以下内容:
1 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用户重新设置密码,如下:
最终顺利完成!
标签:原因 code 查找 客户机 use const 数据库 named ada
原文地址:https://www.cnblogs.com/sunshine5683/p/10046716.html