您的位置:首页 > 数据库 > Oracle

ORACLE使用注意事項总结

2010-09-28 13:11 381 查看
ORACLE SELECT語句使用注意點:

1、欄位的合併顯示

通常SQL SERVER欄位顯示合併,我們使用的是'+',例如:

SELECT a+'-'+b as ab FROM TABLE

而ORACLE的欄位合併顯示,使用的就不是'+',而是'||',例如:

SELECT a||'-'|| as ab FROM TABLE

2、資料庫的匯出:

cmd:

exp system/password@databaeServername owner=system direct=y file=存放路徑.dmp

3、資料庫匯入:

cmd:

imp newtype/newtype@esmt fromuser=flowuser touser=newtype file=d:/flow.dmp ignore=y

4、from dual用法

ORACLE: select sysdate from dual----獲取系統時間

SQL:select getdate()

oracle中一定加from dual這個代碼

序列:

(1).可以為表中的列自動產生值.

(2).由用戶創建資料庫物件,並可由多個用戶共用.

(3).一般用於主鍵或唯一列.

例子:

create sequence my_seq ---創建序列名

start with 1 ---從1開始

increment by 1 ---每次增長1

maxvalue 999999999 ---最大值

minvalue 1 ---最小值

cycle ---迴圈

cache ---緩存

order

從1開始,每次增長1,最大值為999999999,之後又迴圈從1開始.

SQL語句:

insert into mytable values(my_seq,'aaa')

insert into mytable values(my_seq,'bbb')

結果為:

1 aaa

2 bbb

調用:

select my_seq.nextval from mytable ---新值

select my_seq.currval from mytable ---當前值

********************************************************************

第一步:創建SEQUENCE

create sequence s_country_id increment by 1 start with 1 maxvalue 999999999;

第二步:創建一個基於該表的before insert 觸發器,在觸發器中使用該SEQUENCE

create or replace trigger bef_ins_t_country_define

before insert on t_country_define

referencing old as old new as new for each row

begin

select s_country_id.nextval into :new.country_id from dual;

end;

(insert 時就不用關心自動增長列了)

5.發現沒有監聽器解決辦法:

com:

執行:lsnrctl

然後:start
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: