【點(diǎn)擊:】
阿木伯 著
|
|
如何將 primary key 建在其它的表空間上? |
|
- 系統(tǒng)環(huán)境:
1、操作系統(tǒng):Windows 2000
2、數(shù)據(jù)庫: Oracle 8i R2 (8.1.6) for NT 企業(yè)版
3、安裝路徑:C:\ORACLE
- 實(shí)現(xiàn)方法:
利用using index子句實(shí)現(xiàn)
conn system/manager
--創(chuàng)建實(shí)驗(yàn)表空間
create tablespace test datafile
'c:\test.ora' size 5M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
default storage (initial 128K next 1M pctincrease 0)
/
create tablespace test1 datafile
'c:\test1.ora' size 5M
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED
default storage (initial 128K next 1M pctincrease 0)
/
--創(chuàng)建實(shí)驗(yàn)用戶
drop user test cascade;
create user test identified by test default tablespace test;
grant connect,resource to test;
conn test/test
--創(chuàng)建實(shí)驗(yàn)表1
create table a(a number primary key);
col 用戶名 format a10
col 約束名稱 format a15
col 約束類型 format a10
col 表名 format a10
col 列名 format a10
col 約束內(nèi)容 format a20
select a.OWNER 用戶名,
a.CONSTRAINT_NAME 約束名稱,
a.CONSTRAINT_TYPE 約束類型,
a.TABLE_NAME 表名,
b.COLUMN_NAME 列名,
a.SEARCH_CONDITION 約束內(nèi)容
from USER_CONSTRAINTS a,USER_CONS_COLUMNS b
where a.CONSTRAINT_NAME=b.CONSTRAINT_NAME;
用戶名 約束名稱 約束類型 表名 列名 約束內(nèi)容
---------- --------------- ---------- ---------- ---------- ---------
TEST SYS_C001232 P A A
col table_owner format a15
col table_name format a15
col index_name format a15
col tablespace_name format a15
select table_owner,table_name,index_name,tablespace_name from user_indexes;
TABLE_OWNER TABLE_NAME INDEX_NAME TABLESPACE_NAME
--------------- --------------- --------------- ---------------
TEST A SYS_C001232 TEST
--創(chuàng)建實(shí)驗(yàn)表2
create table b
(
b number constraint pr_b
primary key
using index
tablespace test1
);
select a.OWNER 用戶名,
a.CONSTRAINT_NAME 約束名稱,
a.CONSTRAINT_TYPE 約束類型,
a.TABLE_NAME 表名,
b.COLUMN_NAME 列名,
a.SEARCH_CONDITION 約束內(nèi)容
from USER_CONSTRAINTS a,USER_CONS_COLUMNS b
where a.CONSTRAINT_NAME=b.CONSTRAINT_NAME;
用戶名 約束名稱 約束類型 表名 列名 約束內(nèi)容
---------- --------------- ---------- ---------- ---------- -----------
TEST PR_B P B B
TEST SYS_C001232 P A A
select table_owner,table_name,index_name,tablespace_name from user_indexes;
TABLE_OWNER TABLE_NAME INDEX_NAME TABLESPACE_NAME
--------------- --------------- --------------- ---------------
TEST B PR_B TEST1
TEST A SYS_C001232 TEST
|
【最后更新:】 |
|