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的数据库表

相关文章
相关标签/搜索