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
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
相关文章推荐
- Oracle Form 使用注意事項
- ORACLE 中ROWNUM用法总结【天呀,使用这个一定要注意呀。被害了】
- C# 使用Oracle.DataAccess.dll注意事项
- MySQL索引类型总结和使用技巧以及注意事项
- TEC1401.Report开发技术总结 - 第十章 使用BI Publisher开发报表-其他注意事项(5/5)
- oracle 11g使用deferred_segment_creation 延迟段创建特性时遇到的问题总结
- MySQL索引类型总结和使用技巧以及注意事项(转) 4000
- innerHTML使用总结4个注意点
- oracle 11g使用deferred_segment_creation 延迟段创建特性时遇到的问题总结
- 【Oracle】sql的使用总结
- ORACLE时间日期格式使用总结(参考网上资料汇总)
- 【转】Oracle Outline的使用及注意事项
- Tapestry使用示例及注意点总结
- oracle保留字在mybatis的使用注意
- Oracle lsnrctl命令使用总结
- MySQL索引类型总结和使用技巧以及注意事项
- 如何不用oracle client直接使用plsql远程连接oracle数据库以及需要注意的事项
- MySQL索引类型总结和使用技巧以及注意事项
- JavaWeb学习总结(三十五)——使用JDBC处理Oracle大数据
- 在64位的环境中使用VS建立Web项目进行Oracle连接需要注意WebDev是32位的