转自:
1.对数据的导出:
a.备份单张表 :exp userid=scott/centre@orcl tables=(emp) file=d:/emp.dmp
b.备份多张表 :exp userid=scott/centre@orcl tables=(emp,dept) file=d:/emp1.dmp
c.直接导出: exp userid=scott/centre@orcl tables=(emp) file=d:/emp2.dmp
d.备份自己的解决方案 exp userid=scott/centre@orcl onwer=scott file=d:/scott.dmp
e备份任何的解决方案 exp userid=system/centre@orcl onwer=(system.scott) file=d:/system.dmp
2.对数据的导出:
a.恢复自己的表 imp userid=scott/centre@orcl tables=(emp) file=d:/xx.dmp
b.将别人的表恢复到自己 imp userid=system/centre@orcl tables=(emp) file=d:/xx.dmp touser=scott
c.导入自身解决方案: imp userid=scott/centre file=d:\xx.dmp
d.导入其它解决方案:imp userid=system/manager file=d:\xxx.dmp fromuser=system touser=parking
默认情况 imp userid=system/manager full=y file=d:\xxx.dmp
imp userid=system/password1@Oracle所在IP/实例名字 file=d:\testdmp fromuser=system touser=tianjin
exp tongji/tongji213498@orcl file=./2012-12-05.dmp
3.建立用户:
创建用户与授权语法
创建用户--命令:--CREATE USER 名称 IDENTIFIED BY 口令 DEFAULT TABLESPACE "默认表空间名" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK-- 一般属性--PROFILE "DEFAULT":授予默认的权限-- DEFAULT TABLESPACE :默认表空间名-- TEMPORARY TABLESPACE :临时表空间名,默认TEMP-- ACCOUNT :用户状态,默认UNLOCK 未锁定;LOCK 锁定CREATE USER "TEST" PROFILE "DEFAULT"IDENTIFIED BY "test" DEFAULT TABLESPACE "TEST"TEMPORARY TABLESPACE "TEMP"ACCOUNT UNLOCK;--可以写成CREATE USER "TEST" PROFILE "DEFAULT"IDENTIFIED BY "test" DEFAULT TABLESPACE "TEST" ;用户授权--grant "connect,resource,dba" to "someuser" with admin option;-- WITH ADMIN OPTION :管理选项--授予usertest DBA权限grant dba to "usertest" with admin option;--取消授权--REVOKE "RESOURCE" FROM "SCOTT";实例SQL> create user hzsd0703 identified by hzsd0703;再进行授权操作grant connect,resource,create session,create table to hzsd0703;例子s_emp s_dept等脚本:$ORACLE_HOME/rdbms/demo/summit2.sql$ORACLE_HOME/sqlplus/demo/demobld.sqlcreateuser.sql中
set termout off
spool script/Log/createtable.logDROP USER "PARKINGSYSTEM" CASCADE;CREATE USER "PARKINGSYSTEM" PROFILE "DEFAULT" IDENTIFIED BY "PARKINGSYSTEM" DEFAULT TABLESPACE "USERS" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK;GRANT "AQ_ADMINISTRATOR_ROLE" TO "PARKINGSYSTEM";GRANT "CONNECT" TO "PARKINGSYSTEM";GRANT "RESOURCE" TO "PARKINGSYSTEM";spool offexit;Setup.bat中
@echo 欢迎使用停车场后台数据库安装程序!
@echo 系统准备开始安装,请按任意键继续......@echo offpause>nul@echo on@echo 系统开始执行安装,请不要关闭本界面.....@echo off@echo 系统开始执行安装......>>"Setup.log"call 0createFile.bat >nul@echo on@echo 建立文件夹完成......@echo off@echo 建立文件夹完成>>"Setup.log"sqlplus system/admin@10.64.59.12/orcl @createuser.sql@echo on@echo 建立表完成......@echo off@echo 建立表完成>>"Setup.log"@echo on@echo 系统安装完成......@echo off@echo 系统安装完成......>>"Setup.log"@echo on@echo 安装程序已安装完成,请按按任意键退出安装......@echo offpause>nul删除用户以及其下面的所有表:
select username from dba_users --查看已有用户
drop user google cascade --删除用户,并删除其下面的表drop user username --仅仅是删除用户