LINUX下環境下連接oracle 數據庫搭建測試環境

--一、建表空間  sql

CREATE TABLESPACE product  數據庫

DATAFILE '/datafs/orcl/orcl/product03.dbf' size 32000M AUTOEXTEND OFF;bash

 

ALTER TABLESPACE product  ADD服務器

DATAFILE '/datafs/orcl/orcl/product04.dbf' size 32000M AUTOEXTEND OFF;session

--2.建用戶  ide

create user product identified by product   工具

default tablespace product;  ui

 

--3.賦權  spa

grant connect,resource to product;  get

grant create any sequence to product;  

grant create any table to product;  

grant delete any table to product;  

grant insert any table to product;  

grant select any table to product;  

grant unlimited tablespace to product;  

grant execute any procedure to product;  

grant update any table to product;  

grant create any view to product;  

 

查看數據庫源名稱:

SQL> select name from v$database;

NAME
---------
ORCL

 

 

 

四、查看錶空間

SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size FROM dba_tablespaces 

t, dba_data_files d WHERE t.tablespace_name = d.tablespace_name GROUP BY t.tablespace_name; 

五、執行工具導出數據

sh exp.sh

 

exp.sh 內容:

#!/bash
/datafs/f/unload user/password I_LICY

六、--從進入的服務器中某目錄下拷貝文件到另一個服務器目錄下,test是用戶名

scp /datafs/fgg/*.unl test@10.31.57.76:/home/test/xiaobo/SQL

七、執行DDL文件生成庫表

sh t_ddl.sh;

 

t_ddl.sh 文件內容:

echo "**************************** BEGIN PRODUCT ****************************"
#認證部分
if [ "$1" = "" ]
then
 echo "請輸入PRODUCT密碼:";
 read PASSWD;
else  
 PASSWD=$1;
fi


#設置部分
sqlplus -s PRODUCT/$PASSWD<<EOF
set errorlogging on;
alter session set nls_language=american;
set heading off;
set echo off;
set verify off;
set pagesize 0;

 

spool PRODUCT_DDL.SQL.LOG

 

@./SQL/PRODUCT_DDL.SQL


spool off
quit;
EOF
echo "**************************** END   PRODUCT ****************************"

 

八、執行工具導入數據

sh t_dml.sh;

 

t_dml.sh 文件內容:

#!/bash


/home/test/xiao/load -U user/password -F ./SQL/Y.unl -T Y
/home/test/xiao/load -U user/password -F ./SQL/CY_DUR.unl -T CY_DUR

九、select * from all_all_tables where  owner='USER' and num_rows='0'

查看數據爲0的數據庫表

相關文章
相關標籤/搜索