Create scott mode using scripts

Source: Internet
Author: User


Use the script to create the scott mode. First, check my database version SQL> select * from v $ version; BANNER implements Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-ProductionPL/SQL Release 11.2.0.1.0-ProductionCORE 11.2.0.1.0 ProductionTNS for Linux: Version 11.2.0.1.0-ProductionNLSRTL Version 11.2.0.1.0-Production www.2cto.com 1. create a scott demo table by using a script. Very simple. 10G version: -- need to verify (1) cd $ ORACLE_HOME/sqlplus/demo (2) connect with any user identity and run demobld. sqldemobld. SQL creates five tables and fills them with data. After the script is executed, it automatically exits SQL * Plus. Therefore, after the script is run, the SQL * Plus window disappears. Do not be surprised. This is normal. 11g version-tested (1) cd & ORACLE_HOME/rdbms/admin (2) connect to any user and run utlsampl. SQL [oracle @ elvis admin] $ pwd/u01/oracle/product/11.2.0/dbhome_1/rdbms/admin [oracle @ elvis admin] $ sqlplus/as sysdbaSQL * Plus: release 11.2.0.1.0 Production on Sat Oct 13 10:41:21 2012 Copyright (c) 1982,200 9, Oracle. all rights reserved. connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> @ utlsampl. sqlDisconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle @ elvis admin] $ SQL> col username format a15; SQL> set linesize 100; SQL> select username, user_id, account_status from dba_users; USERNAME USER_ID ACCOUNT_STATUS certificate ---------- specified SYS 0 OPENSYSTEM 5 OPENSCOTT 61 OPENOUTLN 9 EXPIRED & found 57 EXPIRED & LOCKEDMDSYS 55 EXPIRED & found 52 EXPIRED & found 51 EXPIRED & found 44 EXPIRED & found 42 EXPIRED & found & LOCKEDDBSNMP 30 EXPIRED & LOCKEDUSERNAME USER_ID ACCOUNT_STATUS certificate ---------- invalid WMSYS 32 EXPIRED & found 43 EXPIRED & found 31 EXPIRED & found 53 EXPIRED & 60 EXPIRED & found 54 EXPIRED & found 14 EXPIRED & found 58 EXPIRED & LOCKEDRUSERNAME USER_ID ACCOUNT_STATUS ---------------------- ------------------------------ ORACLE_OCM 21 EXPIRED & LOCKEDXS $ NULL 2147483638 EXPIRED & LOCKED21 rows selected. 2. create mode without using scripts if you cannot access utlsampl. SQL, you can use the following script to execute (that is, the script that comes with the system is posted, wow haha) www.2cto.com [oracle @ elvis admin] $ cat utlsampl. sqlRem Copyright (c) 1990,200 6, Oracle. all rights reserved. rem namerem utlsampl. SQLRem FUNCTIONRem NOTESRem MODIFIEDRem lburgess 04/02/06-lowercase passwordsRem menash 02/21/01-remove invalid users for security reasons gwood 03/23/99-make all dates Y2K compliantRem jbellemo 02/27/97-dont connect systemRem akolk 08/06/96-bug 368261: adding date formatsRem glumpkin 10/21/92-Renamed from SQLBLD. SQLRem blinden 07/27/92-Added primary and foreign keys to EMP and DEPTRem rlim 04/29/91-change char to varchar2Rem mmoore 04/08/91-use unlimited tablespace privRem pritto 04/04/91-change SYSDATE to 13-JUL-87Rem Mendels 12/07/90-bug 30123; add to_date CILS so language independentRemremrem $ Header: utlsampl. SQL 02-apr-2006.21: 13: 01 lburgess Exp $ sqlbld. sqlremSET termout offset echo off rem CONGDON Invoked in RDBMS at build time. 29-DEC-1988rem OATES: Created: 16-Feb-83 www.2cto.com 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/tigerCREATE 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', 'cler', 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, 'bucke ', '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 '), 7876, 0, 30); insert into emp values (7788, 'adams', 'cler', to_date ('13-JUL-87 ', 'dd-mm-rr ') -7900, 1100, NULL, 20); insert into emp values (7698, 'James ', 'cler', 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 ', 'cler ', 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, 2000); insert into salgrade values (3000, 9999); insert into salgrade values (,); insert into salgrade values ); COMMIT; EXIT Source http://blog.csdn.net/elvis_dataguru/article/details/8066887
 

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.