收藏 oracle 中的SQL

2021-08-29 05:45:55 字數 1122 閱讀 6756

[quote]oracle 中的sql

oracle 日期_:

submitdate=datetime.parse(submitdate).tostring("d-m月-yyyy");

to_date('2002-01-02','yyyy-m-dd')

select count(1) from l_perm where cancel <>'y' and (sysdate-perm_date)>3

在 pl/sql develop 中除錯、作試驗,我寫入以前在 sql server 中的 sql 語句:

insert into ... (............) values (......., '2004-7-20 11:25:36', ....) -- 此語句適用於sql server

居然出錯了!我還以為,oracle 的日期型別分隔符像 access 那樣是 #,我又試了:

insert into ... (............) values (......., #2004-7-20 11:25:36#, ....) -- 此語句適用於ms access

insert into ... (............) values (......., to_date('2004-7-20 11:25:36', 'yyyy-mm-dd hh24:mi:ss'), ....)

to_date、to_char,。

找乙個怎樣輸入、輸出日期型別資料的例子。看到了 timestamp 關鍵字,上面的 sql 語句可以寫成:

insert into ... (............) values (......., timestamp '2004-7-20 11:25:36', ....)

選擇前n條記錄:

可以採用rownum<10即前10條資料 ,格式

select * from t where rownum<10

兩者之間

select * from (select rownum r,a.* from tablename a where rownum <= 100) where r >= 60;

得到序列:

select c_order.nextval as id from dual

[/quote]

Sql語句收藏

1 查詢列表,按照in的排序進行排序 code select select count 0 from picture where album id album id aspiccount from album where id in 5 6,8 1,3 4 order bycharindex ltr...

SQL中的數字格式化 收藏

用sql語句來格式化double型的資料,比如,只取出小數點後面的兩位 一。主要方法 取小數字前數字,不考慮四捨五入 select left 30000.72234 charindex 30000.72234 1 其中 charindex 30000.72234 獲得小數點的位置 1則表示在小數點前...

SQL 收藏 SQL操作全集

sql操作全集 7 d x a0d r d g0e x 下列語句部分是mssql語句,不可以在access中使用。7x k sql分類 ddl 資料定義語言 create,alter,drop,declare 9j3u i l t w r3 z dml 資料操縱語言 select,delete,up...