ORACLE建表空间,授权,导入,导出表

来源:互联网 发布:mac pro拆解 编辑:程序博客网 时间:2024/06/05 14:40
oracle创建表空间和用户授权

SYS用户在CMD下以DBA身份登录:
在CMD中打sqlplus/nolog  //匿名登录
然后再conn/as sysdba    //以dba身份登录

//创建临时表空间
create temporary tablespace bigoa_temp
tempfile 'd:\oracle\product\10.1.0\oradata\orcl\bigoa_temp.dbf'
size 50m
autoextend on
next 50m maxsize 2048m
extent management local;

//创建数据表空间
create tablespace poba
logging
datafile'D:\software\oracle\product\10.2.0\oradata\orcl\poba.dbf'
size 50m
autoextend on
next 50m maxsize 2048m
extent management local;
//查看数据表空间
select tablespace_name from dba_data_files;

//创建用户并指定表空间
create user nwoa identified by oa
default tablespace poba
temporary tablespace temp;
grant connect,resource,dba,CTXAPP,create view to nwoa;
//给用户授予权限
grant connect,resource,dba,CTXAPP,create view to nwoa;
以后以该用户登录,创建的任何数据库对象都属于user_temp和user_data表空间,这就不用在每创建一个对象给其指定表空间了

//修改用户口令
alter user user_name identified by password;

撤权:revoke 权限...  from 用户名;

删除用户命令
drop user nwoa cascade;

//删除表空间
drop tablespace bigoa_temp including contents and datafiles cascade constraints;
//including contents 删除表空间的内容,如果删除表空间之前表空间中有内容,而未加此参数,表空间删不掉
//cascade constraints 同时删除tablespace中表的外键参照

//数据导出
注:退出到cmd命令下再运行下列命令
1、将数据库TEST完全导出,用户名system密码manager,导出到D:daochu.dmp中
   exp pobaoa/oa@orcl file=d:/zyoa0809.dmp full=y  //不用加full=y,加上的意思是连同系统表一起导出
   exp nwoa/oa@orcl file=d:/NW_OA_SUPERINTEND_NEWDCDBINFO.dmp tables=(NW_OA_SUPERINTEND_NEWDCDBINFO) //不用加full=y,加上的意思是连同系统表一起导出
2、将数据库中system用户与sys用户的表导出
   exp system/manager@TEST file=d:daochu.dmp owner=(system,sys)

3、将数据库中的表inner_notify   notify_staff_relat导出
   exp aichannel/aichannel@TESTDB2 file=d:datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat)
  exp swoa/oa@orcl file=f:/swoa11.dmp tables=(OA_CALENDAR)
     exp bigoa/bigoa@orcl file=f:/bigoatemp.dmp tables=(OA_CALENDAR)
4、将数据库中的表table1中的字段field1以“00”开头的数据导出
   exp system/manager@TEST file=d:daochu.dmp tables=(table1) query="where filed1 like '00%'"


//数据导入
注:退出到cmd命令下再运行下列命令
1、将D:daochu.dmp中的数据导入TEST数据库中
   imp aichannel/aichannel@HUST full=y file=d:datanewsmgnt.dmp ignore=y
   有的表已经存在,所以会报错,加上ignore=y就可以了
    
imp nwoa/oa@orclt file=C:\NW20140415.dmp  full=y ignore=y

imp test2/test2@orclt file=J:/DATA/swoa2013-11-21.dmp full=y ignore=y

2、将d:daochu.dmp中的表table1导入
   imp nwoa/oa@orcl file=d:/nwoa1118.dmp tables=(wf_define,PORTAL_PORTLET)

imp nwoa/oa@orclt file=e:/nwoa0404.dmp tables=(PORTAL_USERTEMPLET)


select INSTANCEID,NID,TITLE,NODENAME,ASSIGNER,NODEBEGIN,initiatorname,'办理状态'As blzt  from view_wf_todo where actor='%USERID%' order by nodebegin desc
 sqlplus / as sysdba

修改数据库字段类型
alter table nw_oa_gw_qslc add nr_temp clob;
update nw_oa_gw_qslc set nr_temp=nr,nr=null;
alter table nw_oa_gw_qslc  modify nr clob;
update nw_oa_gw_qslc set nr=nr_temp,nr_temp=null;
alter table nw_oa_gw_qslc drop column nr_temp;


exp nwoa/oa@BJNW file=\\10.213.22.175\nw\%date:~0,10%.dmp  OWNER=nwoa//导出数据库到其他服务器磁盘上

insert into hr_user_baseinfo(sno,user_sno,user_name)
 (select id as sno,code as user_sno ,username as user_name from ou_user);
oracle 从一张中更新另外一张表字段
update a set a.name=(select b.name from b where a.id=b.id),a.adress=(select b.address from b where a.id=b.id) where a.name<>b.name or a.address<>b.address

0 0
原创粉丝点击