創(chuàng)建索引:
創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿(mǎn)足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的富裕網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
自動(dòng)
– 創(chuàng)建 PRIMARY KEY
– 創(chuàng)建 UNIQUE KEY
手動(dòng)
– CREATE INDEX 語(yǔ)句
– CREATE TABLE 語(yǔ)句
create table 語(yǔ)句中 create index
create table new_emp (employee_id number(6) primary key using index
(create index emp_id_idx on
new_emp(employee_id)),
first_name varchar2(20),
last_name varchar2(25));
select index_name, table_name from user_indexes where table_name = 'new_emp';
基于函數(shù)的索引
基于函數(shù)的索引就是一個(gè)基于表達(dá)式的索引
索引表達(dá)式由列、常量、SQL 函數(shù)和用戶(hù)自定義函數(shù)構(gòu)成的
create index upper_dept_name_idx on dept2(upper(department_name));
select * from dept2 where upper(department_name) = 'SALES';
刪除索引
使用 DROP INDEX 命令從數(shù)據(jù)字典中刪除索引:
drop index index;
從數(shù)據(jù)字典中刪除 UPPER_DEPT_NAME_IDX 索引:
drop index upper_dept_name_idx;
刪除索引,您必須是索引的擁有者或者有 DROP ANY INDEX權(quán)限
drop table dept80 purge;
FLASHBACK TABLE 語(yǔ)句
一條語(yǔ)句就可以恢復(fù)到指定時(shí)間點(diǎn)。
恢復(fù)表中的數(shù)據(jù)以及相關(guān)的索引和約束。
可以根據(jù)某一時(shí)間點(diǎn)或者系統(tǒng)改變號(hào)(SCN) 來(lái)恢復(fù)表。
表意外修改的修復(fù)工具:
– 表恢復(fù)到一個(gè)較早的時(shí)間點(diǎn)
– 優(yōu)點(diǎn):易用性、可用性、快速執(zhí)行
– 執(zhí)行到位(Is performed in place)
語(yǔ)法:
flashback table[schema.]table[,
[ schema.]table ]...
to { timestamp | scn } expr
[ { enable | disable } triggers ];
示例:
drop table emp2;
select original_name, operation, droptime from recyclebin;
flashback table emp2 to before drop;
臨時(shí)表
創(chuàng)建臨時(shí)表
create global temporary table cart on commit delete rows;
create global temporary table today_sales
on commit preserve rows as
select * from orders
where order_date = sysdate;
外部表
為外部表創(chuàng)建目錄
創(chuàng)建 DIRECTORY對(duì)象,對(duì)應(yīng)外部數(shù)據(jù)源所在的文件系統(tǒng)上的目錄。
create or replace directory emp_diras '/.../emp_dir';
grant read on directory emp_dir to ora_21;
創(chuàng)建外部表
create table <table_name>
( <col_name> <datatype>, ... )
organization external
(type <access_driver_type>
default directory <directory_name>
access parameters
(...) )
location ('<location_specifier>')
reject limit [0 | <number> | unlimited];
使用ORACLE_LOADER 驅(qū)動(dòng)創(chuàng)建外部表
create table oldemp (
fname char(25), lname char(25))
organization external
(type oracle_loader
default directory emp_dir
access parameters
(records delimited by newline
nobadfile
nologfile
fields terminated by ','
(fname position ( 1:20) char,
lname position (22:41) char))
location ('emp.dat'))
parallel 5
reject limit 200;
查詢(xún)外部表
select * from oldemp
使用ORACLE_DATAPUMP驅(qū)動(dòng)創(chuàng)建外部表:
create table emp_ext
(employee_id, first_name, last_name)
organization external
(
type oracle_datapump
default directory emp_dir
location
('emp1.exp','emp2.exp')
)
parallel
as
select employee_id, first_name, last_name
from employees;
分享名稱(chēng):SQL基礎(chǔ)之索引、閃回、臨時(shí)表(十八)
標(biāo)題來(lái)源:http://muchs.cn/article18/johpgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動(dòng)網(wǎng)站建設(shè)、做網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、云服務(wù)器、網(wǎng)站營(yíng)銷(xiāo)、營(yíng)銷(xiāo)型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)