Prior to installing the 12c version, recent exercises have found no tables for Scott users and 11g emp,dept, etc. Then try to unlock the user and find that the user does not exist
sql> alter user Scott account Unlock;alter user Scott account unlock *error @ line 1:ora-01918:user ' Scott ' does not exist
Create user manually, error, and 11g not quite the same
Sql> create user Scott identified by Oracle;create user Scott identified by Oracle *error on line 1:ora-6509 6:invalid common user or role name
The reason is related to pdb,cdb. PDB and CDB is a new feature of 12c, not specifically learned, do not know is God horse meaning, but can refer to this article: http://www.cnblogs.com/tzetze/p/3665903.html
Viewing error ora--65096
sql> !oerr ora 6509665096, 00000, "Invalid common user or role name "// *cause: an attempt was made to create a common user or role with a name// that wass not valid for common users or roles. in addition to // the usual rules for user and role names, common user and Role // names must start with C## or c## and consist only of ASCII // characters.// *action: specify a valid common user or role name.//
In CDB, the user is able to #开头 in C #.
Try to @/u01/app/oracle/product/12.1.0/db_1/rdbms/admin/utlsampl.sql in SQL, also not, because there is a problem with the user name
So you rewrite the script, the steps are as follows:
Current path
[Email protected] ~]$ pwd
/home/oracle
Copy a copy to the current directory
[Email protected] ~]$ cp/u01/app/oracle/product/12.1.0/db_1/rdbms/admin/utlsampl.sql.
Rename file to Scott.sql:
[Email protected] ~]$ MV Utlsampl.sql scott.sql
Modify Scott.sql:
The main is to change the Scott user-related statements to C # #scott, delete the last exit, modified Scott.sql as follows:
Scott.sql
set termout offset echo offdrop user c# #SCOTT cascade;create user c# #scott identified by tiger;grant connect,resource,unlimited tablespace to c# #scott container=all;alter user c# #scott default tablespace users; alter user c# #scott temporary tablespace temp; connect c# #SCOTT/tigercreate table dept (DEPTNO Number (2) constraint pk_dept primary key, dname varchar2 (14)  ,    LOC VARCHAR2 ( ) ; create table emp (Empno number (4) CONSTRAINT pk_emp primary key, ename varchar2 (Ten), JOB  VARCHAR2 (9), mgr number (4), hiredate date, &Nbsp; sal number (7,2), comm number (7,2), Deptno number (2) constraint fk_deptno references dept); INSERT INTO DEPT VALUES (' ACCOUNTING ', ' new york '); insert into dept values ("DALLAS");insert into dept values (' SALES ', ' CHICAGO ');insert into dept values (+, ' OPERATIONS ', ' BOSTON '); INSERT into emp values (7369, ' SMITH ', ' Clerk ', 7902,to_date (' 17-12-1980 ', ' dd-mm-yyyy '), 800,null,20); Nsert 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); Nsert into emp values (7839, ' KING ', ' president ', null,to_date (' 17-11-1981 ', ' dd-mm-yyyy '), 5000,NULL , 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)    ,    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;
Test:
sqlplus / as sysdbasql> @/home/oracle/scott.sql; sql> conn c# #scott/tigerconnected.sql> select table_name from user_tables; Table_ NAME--------------------------------------------------------------------------------Salgradebonusdeptempsql > select * from SALGRADE; GRADE Losal hisal---------- ---------- ---------- 1 700 1200 2 1201 1400 3 1401 2000 4 2001 3000 5 3001 9999
Ok!
This article is from the "Adela" blog, make sure to keep this source http://adelazhu.blog.51cto.com/9455045/1680817
Scott Account and table issues in Oracle 12c