一,
1.Oracle 建立表空間,使用者,指派(簡裝)
C:\Documents and Settings\Administrator>sqlplus /nolog
SQL> conn /as sysdba
2.删除使用者
drop user username cascade;
3.建立自增表表空間
SQL> create tablespace 表空間 datafile 'E:\oracle\product\10.2.0\oradata\表空間.dbf' size 50m autoextend on;
4.建立使用者
create user username identified by password default tablespace 表空間;
5.指派
grant dba to username;
exit
6.導入資料庫
在本地導入資料庫
C:\>imp 使用者名/使用者密碼@執行個體名 file=G:\oracle\oracle.bak full=y
7.導入資料庫
導出非本地資料庫
C:\>exp rows=y owner=使用者名 file="E:\289\庫名_201107.dmp" log="e:\289\庫名_201107.log"額外操作
增加表空間
SQL> alter tablespace sjpt resize 500m;
ORA-32773: 不支援對小檔案表空間 SJPT 的操作
如果報以上錯誤則換為:
SQL> alter tablespace sjpt add datafile 'd:\oradata\sjpt1.dbf' size 500m reuse autoextend on next 100m;
二,
http://jun0325.javaeye.com/blog/603783
2.1.檢視所有表空間大小:
select tablespace_name,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
2.2.已經使用的表空間大小:
select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;
2.3. 是以使用空間可以這樣計算:
select a.tablespace_name,total,free,total-free used from
( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files
group by tablespace_name) a,
( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space
group by tablespace_name) b
where a.tablespace_name=b.tablespace_name;
最近一直在導入Oracle的很多備份到新的伺服器上的新的Oracle上,但是導入新伺服器的Oracle上後,發現使用的仍然是之前預設使用的USERS表空間,并非使用我自行建立的表空間,于是從網上索羅了很多修改表空間的方法終于搞定了。
主要用到了下面幾個sql:
(1) 查詢占用該表空間的表: select segment_name,bytes/1024/1024 from dba_segments where tablespace_name='ts_name' and segment_type='TABLE';
(2) 修改表所使用的表空間: alter table buffalo_wf_processinstance move tablespace "ts_name";
(3) 修改帶有大字段表的表空間: alter table tb_name(表名) move tablespace tbs_name(表空間名) lob(col_lob1(字段名),col_lob2) store as(tablesapce tbs_name);
(4) 對于有索引的表重建索引: alter index PK_T_CMS_CATALOG(索引名) rebuild; 不知道各位高手在遇到這種情況的時候是如何修改它的表空間?
三,
3.1
檢視表空間是否為自增??
---如果有多個資料檔案,則單個顯示分開顯示、
select TABLESPACE_NAME, AUTOEXTENSIBLE from dba_data_files;
----表空間沒有自增屬性,而表空間中的資料檔案是可以自增的,是以間接達到表空間自增
select distinct TABLESPACE_NAME, AUTOEXTENSIBLE from dba_data_files;
3.2
檢視資料檔案,有時會有多個,而且不在同一目錄,是以需要用到
select * from dba_data_files;
2011-01-06