tyson記事本

Google & man(Unix) are your best friends!

Skip to: Content | Sidebar | Footer

Category: 2.DataBase

Oracle: 如何在 SQL 敘述中使用包含 & 字元的字串常數

2 January, 2007 (16:19) | Oracle | By: tyson

ref: http://www.cine.idv.tw/Learning/ComputerScience/Database/oracle/AppNotes/appnote-59824f555728-sql-65588ff04e2d4f7f75285305542b-5b57514376845b574e325e386578/

shortie 發現 TOAD 的 SQL Editor ,會把 ‘&’ 字元後的字串,當成變數名稱,造成無法直接將欄位之值,更新為包含 ‘&’ 字元的字串…

問題描述
INSERT INTO DTBDRG (
DRG_CODE, DRG_NHI_CODE, DRG_NAME, DRG_JD_FLAG,
DRG_SPEC, DRG_UNIT, DRG_CHARACTER, DRG_TEST_FLAG, DRG_BRAND)
VALUES (
‘1CL100′, ‘A042448100′, ‘CLOPINE 100mg (Clozapine) ‘, ‘ ‘,
‘100mg ‘, ‘Tab ‘, ‘ ‘, ‘ ‘, ‘瑞士[1.2.2.1&~2]‘);
在 TOAD 中無法執行。
解決方案
這嚴格說起來並不能算是 PL/SQL 問題,而是 TOAD 的 SQL [...]

Can one drop a column from a table?

30 December, 2005 (11:29) | Oracle, SQL | By: tyson

Can one drop a column from a table?
Can one drop a column from a table?From Oracle8i one can DROP a column from a table. Look at this sample script, demonstrating the ALTER TABLE table_name DROP COLUMN column_name; command.
Other workarounds: 1. SQL> update t1 set column_to_drop = NULL;
SQL> rename t1 to t1_base;
SQL> create view t1 as [...]

當預約日期小於今天就不要show

15 January, 2005 (12:34) | Oracle | By: tyson

select * from tt where to_date(’2004′ || ‘/’ || tmonth || ‘/’ || tday,’yyyy/mm/dd’) > mdate

給我整個月,其餘免談

15 January, 2005 (12:34) | Oracle | By: tyson

select create_date from break_report
where create_date between to_date(’2004/07/01 00:00:00′,’YYYY/MM/DD HH24:MI:SS’)
and last_day(to_date(’2004/07/01 23:59:59′,’YYYY/MM/DD HH24:MI:SS’))

西元年 -> 民國年

15 January, 2005 (12:31) | Oracle | By: tyson

Select (to_number(to_char(sysdate,’yyyy’)) – 1911)to_char(sysdate,’/MM/DD HH24:MI:SS’) AS AAD from dual;
select to_char(add_months(sysdate,-(1911*12)),’YY/MM/DD HH24:MI:SS’) from dual;
select add_months(sysdate,-(1911*12)) from dual

Oracle 常用文章查詢

15 January, 2005 (12:22) | 2.DataBase, Oracle | By: tyson

Puget Sound Oracle Users Group
http://www.psoug.org/ 
Database Journal Oracle Database Administration News, Articles, Scripts, Tutorials, Forums, And Resources for the Oracle Database Professional:
http://www.databasejournal.com/features/oracle/
METALINK:
http://metalink.oracle.com
Oracle Technology Network(OTN):
http://www.oracle.com/technology/index.html
Oracle FAQ’s:
http://www.orafaq.com/