windows下Oracle11G指令碼建使用者、表空間、表

luckyfriends發表於2015-04-07
@echo off
set uname=%1%
set pword=%2%
echo %uname%
echo %pword%
echo @echo off>C:\createUser.sql
echo create temporary tablespace user_temp>>C:\createUser.sql
echo tempfile 'C:\app\Administrator\oradata\user_temp.dbf'>>C:\createUser.sql
echo size 50m>>C:\createUser.sql
echo autoextend on>>C:\createUser.sql
echo next 50m maxsize 20480m>>C:\createUser.sql
echo extent management local;>>C:\createUser.sql
echo create tablespace user_data>>C:\createUser.sql
echo logging>>C:\createUser.sql
echo datafile 'C:\app\Administrator\oradata\user_data.dbf'>>C:\createUser.sql
echo size 50m>>C:\createUser.sql
echo autoextend on>>C:\createUser.sql
echo next 50m maxsize 20480m>>C:\createUser.sql
echo extent management local;>>C:\createUser.sql
echo create user %uname% identified by %pword%>>C:\createUser.sql
echo default tablespace user_data>>C:\createUser.sql
echo temporary tablespace user_temp;>>C:\createUser.sql
echo grant connect,resource,dba to %uname%;>>C:\createUser.sql
echo exit;>>C:\createUser.sql

echo @echo off>C:\createTable.sql
echo CREATE TABLE DEPT>>C:\createTable.sql
echo (DEPTNO NUMBER(2) CONSTRAINT PK_DEPT PRIMARY KEY,>>C:\createTable.sql
echo DNAME VARCHAR2(14),>>C:\createTable.sql
echo LOC VARCHAR2(13));>>C:\createTable.sql
echo INSERT INTO DEPT VALUES(1,'IT','XIAN');>>C:\createTable.sql
echo INSERT INTO DEPT VALUES(2,'core','XIAN');>>C:\createTable.sql
echo INSERT INTO DEPT VALUES(3,'wireless','XIAN');>>C:\createTable.sql
echo COMMIT;>>C:\createTable.sql
echo exit;>>C:\createTable.sql

sqlplus / as sysdba @C:\createUser.sql 

sqlplus %uname%/%pword%@orcl @C:\createTable.sql
exit 0

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14710393/viewspace-1518343/,如需轉載,請註明出處,否則將追究法律責任。

相關文章