新建表空间
create tablespace WMS_DATA datafile
'D:\sk_data\WMS_data01.dbf' size
500M autoextend on next 50M extent management local uniform
size 512k;
ALTER TABLESPACE WMS_DATA ADD DATAFILE
'D:\sk_data\WMS_data02.dbf' SIZE
500M autoextend on next 50M ;
ALTER TABLESPACE WMS_DATA ADD DATAFILE
'D:\sk_data\WMS_data03.dbf' SIZE
500M autoextend on next 50M ;
ALTER TABLESPACE WMS_DATA ADD DATAFILE
'D:\sk_data\WMS_data04.dbf' SIZE
500M autoextend on next 50M ;
2、删除表空间,同时删除数据文件:
drop tablespace wms_data including contents and datafiles;
查看表空间大小:
round(((a.bytes-b.bytes)/a.bytes)*100,2) "percent_used"
from
(select tablespace_name,sum(bytes) bytes from dba_data_files group by tablespace_name) a,
(select tablespace_name,sum(bytes) bytes,max(bytes) largest from dba_free_space group by tablespace_name) b
where a.tablespace_name=b.tablespace_name
order by ((a.bytes-b.bytes)/a.bytes) desc;
新建用户
Create user wms identified by minsheng default tablespace
WMS_DATA temporary tablespace temp;
Grant connect,resource to wms;
删除用户及表
(2)导入数据库
imp 用户名/密码@数据库名 file=dmp文件地址 full=y statistics=none
数据导出:
1 将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中
exp system/manager@TEST file=d:\daochu.dmp full=y
2 将数据库中system用户与sys用户的表导出
exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)
3 将数据库中的表table1 、table2导出
exp system/manager@TEST file=d:\daochu.dmp tables=(table1,table2)
4 将数据库中的表table1中的字段filed1以"00"打头的数据导出
exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=\" where filed1 like '00%'\"
上面是常用的导出,对于压缩我不太在意,用winzip把dmp文件可以很好的压缩。
不过在上面命令后面 加上 compress=y 就可以了
数据的导入
1 将D:\daochu.dmp 中的数据导入 TEST数据库中。
imp system/manager@TEST file=d:\daochu.dmp
上面可能有点问题,因为有的表已经存在,然后它就报错,对该表就不进行导入。
在后面加上 ignore=y 就可以了。
2 将d:\daochu.dmp中的表table1 导入
imp system/manager@TEST file=d:\daochu.dmp tables=(table1)
3. 使用imp工具导入dmp数据文件
imp system/123456@orcl file=c:\jandardb.dmp fromuser=devloc touser=scm log=c:\log.txt
基本上上面的导入导出够用了。不少情况我是将表彻底删除,然后导入。
注意:
你要有足够的权限,权限不够它会提示你。
数据库时可以连上的。可以用tnsping TEST 来获得数据库TEST能否连上。
2.更改用户的表空间限额:
A:GRANT UNLIMITED TABLESPACE TO skate;
这种方式是全局性的,不对用户做表空间限额控制。
B:alter user skate quota unlimited on skate_ts;
这种方式是针对特定的表空间的.
3. 可以分配自然也可以回收:
A: revoke unlimited tablespace from skate;
B: alter user skate quota 0 on SKATE_TS;
数据导出:
exp hkb/hkb@boss_14 full=y file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbfull.log;
导出注意事项:导出的是当前用户的的数据,当前用户如果有DBA的权限,则导出所有数据!
同名用户之间的数据导入:
imp hkb/hkb@xe file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbimp.log full=y
不同名之间的数据导入:
imp system/test@xe fromuser=hkb touser=hkb_new file=c:\orabackup\hkbfull.dmp
log=c:\orabackup\hkbimp.log;
1、如果有删除用户的权限,则可以:
drop user user_name cascade;
加了cascade就可以把用户连带的数据全部删掉。
删除后再创建该用户。
--创建管理员用户
create user 用户名 identified by 密码 default tablespace space_data(表空间名称) temporary tablespace space_temp(临时表空间名称);
--授权
grant connect,dba to 用户名;
--修改限额
ALTER USER "用户名" QUOTA UNLIMITED ON SPACE_DATA(表空间名称);
--查看所有用户对象
select uo.object_name,uo.object_type from user_objects uo where uo.object_type<>'LOB' order by uo.object_type desc
2、如果没有删除用户的权限,则可以执行:
select 'drop table '||table_name||';'
from cat
where table_type='TABLE'
将会输出一批删除表的sql语句,这些SQL语句执行一下就可以了。(需要有drop table的权限)