日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
送你51個(gè)Oracle常用語句,看了絕不后悔~

1, 連接數(shù)據(jù)庫;

成都創(chuàng)新互聯(lián)是一家集網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)站頁面設(shè)計(jì)、網(wǎng)站優(yōu)化SEO優(yōu)化為一體的專業(yè)網(wǎng)站制作公司,已為成都等多地近百家企業(yè)提供網(wǎng)站建設(shè)服務(wù)。追求良好的瀏覽體驗(yàn),以探求精品塑造與理念升華,設(shè)計(jì)最適合用戶的網(wǎng)站頁面。 合作只是第一步,服務(wù)才是根本,我們始終堅(jiān)持講誠信,負(fù)責(zé)任的原則,為您進(jìn)行細(xì)心、貼心、認(rèn)真的服務(wù),與眾多客戶在蓬勃發(fā)展的市場環(huán)境中,互促共生。

connect scott/123456;

斷開數(shù)據(jù)庫

disconn;

2, 查看表結(jié)構(gòu)

describe scott.emp;

3, 查看數(shù)據(jù)表

select empno,job,mgr,sal;

4,將緩沖區(qū)中的 sql 語句保存到文件

save scott_emp_query.sql

5,將文件內(nèi)容讀入到緩沖區(qū)中

get scott_emp_query.sql list

6,使用 start 命令讀取并運(yùn)行 sql 文件

start scott_emp_query.sql

7, 將緩沖區(qū)內(nèi)容復(fù)制到名為 afiedt.buf 文件 (這個(gè)是默認(rèn)文件) 中

edit

8,將輸出結(jié)果保存到指定文件中

spool scott_emp_outcome.txt append

9, 帶變量的語句 &

select empno,ename,mgr,sal,deptno

from scott.emp

where empno >=&temp;

10, 帶兩個(gè)變量的語句 (兩次輸入)

select &column_name,deptno

from scott.emp

where &column_name>=7850;

11, 帶兩個(gè)變量的語句(一次輸入)

select &&column_name ,deptno

from scott.emp

where &&column_name>=7850;

12, 不顯示 “原值” 和 “新值” 信息

set veryify off;(on 是顯示)

新招: 反斜杠 "/" 再次運(yùn)行上面的查詢

13,設(shè)置變量定義字符

set define '@'(設(shè)置以后定義變量的字符就變?yōu)?@,& 無效)

14,執(zhí)行 sql 文件的語句

@ E:\TEMP\temp.sql (此處應(yīng)當(dāng)注意,路徑是區(qū)分大小寫的)

15,使用 define 查看常量

define;

16, 設(shè)置常量

define temp=7850

查看常量

define temp

刪除常量

undefine temp

17, 使用 column 設(shè)置輸出格式

column empno heading '員工編號(hào)' format 9999column ename heading '員工姓名' format a10column mgr heading '上級(jí)編號(hào)' format 9999column hiredate heading '受雇日期' justfify centercolumn sal heading '員工工資' format $999,999.99select empno,ename,mgr,hiredate,salfrom scott.emp;

18, 設(shè)置一頁顯示多少行數(shù)據(jù)

set pagesize 20

19, 設(shè)置一行顯示多少字符

set linesize 20

20, 設(shè)置頁眉頁腳

ttitle 頁眉, btitle 頁腳

21,break 命令用來分組,compute 命令用來計(jì)算和

break on deptno;

compute sum of sal on deptno;

select empno,ename,mgr,sal,deptno

from scott.emp order by deptno;

22, 清除 column 格式

clear columns

23, 創(chuàng)建***性表空間

create tablespace myspace

datafile '文件路徑'

size 文件大小

autoextend on next 自動(dòng)增加大小

maxsize 文件***值

語法說明:1,temporary|undo(創(chuàng)建撤銷表空間)2,teblespace_name 3,datafile|tempfile'file_name'4,size5,reuse 若存在,則刪掉并重新創(chuàng)建6,autoextend off|on7,next number 自動(dòng)擴(kuò)展的大小8,maxsize unlimited|number 指定數(shù)據(jù)文件***大小9,mininum extent number 盤區(qū)可以分配到的最小尺寸10,blocksize number 設(shè)置數(shù)據(jù)塊大小11,online|offline 12,logging|nologging13,force logging 強(qiáng)制表空間數(shù)據(jù)庫對(duì)象任何操作都產(chǎn)生日志,否定 1214,default storage storage 指定保存在表空間中的數(shù)據(jù)庫對(duì)象默認(rèn)存儲(chǔ)參數(shù)15,compress|nocompress 是否壓縮數(shù)據(jù)(消除列中的重復(fù)值)16,permanent|temporary 指定表空間中數(shù)據(jù)的保存形式17,extent management dictionary(數(shù)據(jù)字典形式管理)|local(本地化形式管理)18,autoallocate|uniform size number 右邊為指定表中盤區(qū)大小 19,segment space management auto |manual 指定表空間中段的管理方式

24,查看表空間屬性

select * from dba_tablespace wheretablespace_name='表空間名';

25, 修改表空間狀態(tài)

alter tablespace 表空間名 表空間狀態(tài);

26,修改表空間名字

alter tablespace 表空間名 1 rename to 表空間名 2;

27,利用數(shù)據(jù)字典查看空閑空間信息

select * from dba_free_space where tablespace_name='表空間名稱';

28, 利用數(shù)據(jù)字典查看表空間數(shù)據(jù)文件信息

select * from dba_data_files wheretablespace_name='表空間名稱';

29, 修改表空間對(duì)應(yīng)的數(shù)據(jù)文件大小

alter database

datafile '表空間文件路徑名稱'

resize 大小

30, 為表空間增加新的數(shù)據(jù)文件

alter tablespace myspace

add datafile '數(shù)據(jù)文件路徑名稱'

size 大小

autoextend on next 自增大小 maxsize ***值;

31, 刪除 myspace 表空間數(shù)據(jù)文件

alter tablespace myspace

drop datafile '數(shù)據(jù)文件名稱';

32,修改 myspace 表空間中數(shù)據(jù)文件的自動(dòng)擴(kuò)展性

alter database

datafile '表空間文件路徑名稱'

autoextend off;

33, 設(shè)置表空間文件狀態(tài)為 offline drop

alter database

datafile '表空間路徑名稱'

offline drop;

34, 移動(dòng)表空間中的數(shù)據(jù)文件

(1)alter tablespace 表空間名稱 offline; 先設(shè)置表空間狀態(tài)為 offline

(2) 手動(dòng)操作,將磁盤中的表空間數(shù)據(jù)文件移動(dòng)到新的路徑

(3) 使用 alter tablespace 語句修改表空間文件路徑名稱

alter tablespace myspace

rename datafile '表空間路徑名稱'

to

'新的表空間路徑名稱';

(4) 修改 myspace 表空間狀態(tài)

alter tablespace 表空間名稱 online;

35, 刪除表空間

drop tablespace 表空間名稱

including contents and datafiles;

36, 創(chuàng)建臨時(shí)表空間

create temporary tablespace 表空間名稱

tempfile '表空間路徑名稱'

size 大小

autoextend on next 自增大小 maxsize ***大小;

37, 創(chuàng)建臨時(shí)表空間,將所在組指定為 group1

create temporary tablespace 表空間名稱

tempfile '表空間路徑名稱'

size 大小

tablespace group group1;

38, 修改臨時(shí)表空間組

alter tablespace 臨時(shí)表空間名稱 tablespace group group2;

39, 創(chuàng)建大文件表空間

create bigfile tabliespace mybigspace

datafile '表空間路徑名稱'

size 大小;

40, 修改默認(rèn)表空間

alter database default tablespace 表空間名稱;

41, 創(chuàng)建事物級(jí)臨時(shí)表

create global temporary table temp_student(

)on commit delete rows(事物級(jí)別的意思);

42, 使用事物級(jí)別臨時(shí)表

select * from temp_student;

commit; 提交事物。

提交后表還在,但數(shù)據(jù)被清除

43, 創(chuàng)建會(huì)話臨時(shí)表

create global temporary table temp_book(

)on commit preserve rows(會(huì)話級(jí)別的意思);

commit;

斷開該用戶連接才會(huì)清除數(shù)據(jù)

44,讀取外部文件

首先要在對(duì)應(yīng)路徑下有文件

然后 create directory external_card as'E:\external';

創(chuàng)建對(duì)應(yīng)路徑

接下來就是創(chuàng)建外部表

create table e_card(

對(duì)應(yīng)的數(shù)據(jù)

)organization external(

// 里邊這一團(tuán)是什么東西噢

type oracle_loader// 指定訪問外部數(shù)據(jù)文件的驅(qū)動(dòng)程序,oracle 默認(rèn)為 oracle_loader

default directory external_card // 對(duì)應(yīng)上一步路徑

access parameters(

fields terminated by ',')

location ('card.txt')

);

45,reject limit 句子的使用

外部表易出錯(cuò),用這個(gè)就允許有無數(shù)個(gè)錯(cuò)誤

create table e_card(

對(duì)應(yīng)的數(shù)據(jù)

)organization external(

type oracle_loader

default directory external_card

access parameters(

fields terminated by ',')

location ('card.txt')

)reject limit unlimited;

46, 將錯(cuò)誤數(shù)據(jù)存儲(chǔ)到指定文件

create table e_card(

對(duì)應(yīng)的數(shù)據(jù)

)organization external(

type oracle_loader

default directory external_card

access parameters(

records delimited by newline

badfile 'card_bad.txt'

fields terminated by ',')

location ('card.txt')

);

47, 錯(cuò)誤信息日志文件

create table e_card(

對(duì)應(yīng)的數(shù)據(jù)

)organization external(

type oracle_loader

default directory external_card

access parameters(

records delimited by newline

badfile 'card_bad.txt'

logfile 'card_log.txt'

fields terminated by ',')

location ('card.txt')

);

48, 創(chuàng)建范圍分區(qū)表

create table part_book(

數(shù)據(jù)庫內(nèi)容

)partition by range(booktime)(

partition part1 values less than ('01-1 月 - 2008')tablespacemytemp1,

partition part2 values less than ('01-1 月 - 2009')tablespacemytemp2,

partition part1 values less than (maxvalue)tablespacemytemp3

)

49, 創(chuàng)建散列分區(qū)表

create table part_book(

數(shù)據(jù)庫內(nèi)容

)partition by hash(bid)(

partition part1 tablespace mytemp1,

partition part2 tablespace mytemp2,

)

50, 創(chuàng)建列表分區(qū)表

create table part_book(

數(shù)據(jù)庫內(nèi)容

)partition by list(bookpress)(

partition part1 values ('清華大學(xué)出版社') tablespace mytemp1,

partition part1 values ('嶺南師范出版社') tablespace mytemp2

)

51,創(chuàng)建組合范圍散列分區(qū)表

create table part_book(

數(shù)據(jù)庫內(nèi)容

)partition by range(booktime)

subpartition by hash(bid)

subpartitions 2 store in(mytemp1,mytemp2)

(

partition part1 values less than ('01-1 月 - 2008'),

partition part1 values less than ('01-1 月 - 2009'),

partition part1 values less than (maxvalue)

);


分享標(biāo)題:送你51個(gè)Oracle常用語句,看了絕不后悔~
文章路徑:http://www.dlmjj.cn/article/cdgceic.html