Rebuild SCOTT users and SCOTT stories

Source: Internet
Author: User

Rebuild SCOTT users and SCOTT stories

Oracle was first learned from the dept and emp tables under scott, and is still used to testing under scott. Sometimes to facilitate testing, scott users need to be rebuilt to provide a completely new test environment, where the record of the process of rebuilding scott users is recorded.

1. scott user profile
SCOTT is the name of an example user in the Oracle database. Its function is to provide some simple application examples for beginners, but it is locked by default. SCOTT's default password is tiger. The following table is emp and dept. The relationship between these tables demonstrates some basic principles of relational databases. Oracle generally uses this user as an example, this user is generally used in Oracle books and textbooks. It is not necessary for Oracle itself. If you do not want to use it, you can delete it (if you do not create other objects under it ).

2. Prepare the environment
We tested Oracle 10 Gb to delete scott users.

Click (here) to fold or open

C: \ Users \ Administrator> sqlplus sys/hoegh as sysdba

SQL * Plus: Release 10.2.0.4.0-Production on Wednesday May 13 10:24:10 2015

Copyright (c) 1982,200 7, Oracle. All Rights Reserved.

Connect:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0-64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

SQL>

SQL> select * from v $ version;

BANNER

----------------------------------------------------------------

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0-64bi

PL/SQL Release 10.2.0.4.0-Production

CORE 10.2.0.4.0 Production

TNS for 64-bit Windows: Version 10.2.0.4.0-Production

NLSRTL Version 10.2.0.4.0-Production

SQL>

SQL> drop user scott cascade;

The user has been deleted.

SQL>

3. Rebuilding scott users
Oracle provides the scott user's reconstruction script, which is located in the ORACLE_HOME \ RDBMS \ ADMIN directory and named utlsampl. SQL. Run the script in sys as follows:

SQL>
 
SQL> show user

The USER is \ "SYS \"

SQL>

SQL> @ C: \ oracle \ product \ 10.2.0 \ db_1 \ RDBMS \ ADMIN \ utlsampl. SQL

From Oracle Database 10g Enterprise Edition Release 10.2.0.4.0-64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options disconnected

Open

C: \ Users \ Administrator>
After the script is executed, the system automatically releases SQL * plus. Next, we connect to the scott user and check whether the script is successfully executed.

C: \ Users \ Administrator> sqlplus scott/tiger

SQL * Plus: Release 10.2.0.4.0-Production on Wednesday May 13 10:34:29 2015

Copyright (c) 1982,200 7, Oracle. All Rights Reserved.

Connect:

Oracle Database 10g Enterprise Edition Release 10.2.0.4.0-64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from cat;

TABLE_NAME TABLE_TYPE

-----------------------------------------

DEPT TABLE

EMP TABLE

BONUS TABLE

SALGRADE TABLE

SQL> select * from dept;

DEPTNO DNAME LOC

-------------------------------------

10 ACCOUNTING NEW YORK

20 RESEARCH DALLAS

30 SALES CHICAGO

40 OPERATIONS BOSTON

SQL>

SQL>

4. utlsampl. SQL script content
There are many scripts in the ORACLE_HOME \ RDBMS \ ADMIN directory. utlsampl. SQL is only one of them. If you are interested in these scripts, you will also find some benefits. Here, let's take a look at the utlsampl. SQL script content.

Rem Copyright (c) 1990,199 6, 1997,199 9, 2001 by Oracle Corporation
Rem NAME
Rem utlsampl. SQL
Rem FUNCTION
Rem NOTES
Rem MODIFIED
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 CILS so language independent
Rem
Rem
Rem $ Header: utlsampl. SQL 21-feb-01.18: 15: 30 menash 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, 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, 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 \'), 0, 30 );
INSERT INTO EMP VALUES
(7876, \ 'adams \ ', \ 'clerk \', 7788, to_date (\ '13-JUL-87 \ ', \ 'dd-mm-rr, 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,120 0 );
Insert into salgrade values (1400 );
Insert into salgrade values (2000 );
Insert into salgrade values (4,2001, 3000 );
Insert into salgrade values (5, 3001, 9999 );
COMMIT;
EXIT
The script is mainly divided into several parts,
The first part is the remarks Section, with the Rem keyword at the beginning of the line, describing the evolution process of utlsampl. SQL script;
The second part is the drop object. Let's take a look at the yellow-marked statement. That is to say, the drop user statement prepared in the environment is purely superfluous, and Oracle has already thought of it for us;
The third part is to create a table and insert data.

5. Who is scott?

From the first commercial version of Oracle to the present, oracle's default database has all the users whose names are scott and whose passwords are tiger. What exactly does scott come from? How can we keep it rare in our oracle version.

This is about to be traced back to Oracle's entrepreneurial stage. In June 1977, Accenture, Bob Miner, and Ed Oates jointly established a computer company named Software Development Lab (SDL) in Silicon Valley, the three-person Company was the predecessor of ORACLE, which later became the dominant database provider. At that time, herison was 32 years old. He was just as old as me. Because of his contract relationship, he was not able to come out in his original company. He was just a programmer. He can't survive. He always needs someone who writes code. The first programmer in the company appeared. His name is scott, and his cat name is trigger, it may be for the sake of the first programmer, so we have the user scott and have never forgotten it.

In March 1983, RSI released the third edition of ORACLE. Miner and Scott used the C language to develop the third edition under the high pressure of herison, using it to write ORACLE software is also risky, but there is no other way. It soon proved how correct it was: C compiler is cheap and effective, and has good portability.

However, this third edition is not over yet. Scott left Oracle, and perhaps the endless changes in c development and initial stages left scott unable to bear. The Bull chose to leave the company and sell his 4% million shares, but after scott leaves Oracle, he is still confused in the database development market. He founded PointBase, which is a good embedded database, but it seems to be written in java, I have also used development projects. The Daniel did not think that Oracle, which was written by him in the future, is the database giant in the future, and the 4% is equivalent to several hundred million US dollars.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.