Oracle常用的代碼片
對字段操作 |
操作方法 |
更新字段名 |
alter table TABLE_NAME rename column column_old to column_new; |
添加字段 |
alter table TABLE_NAME add COLUMN_NAME varchar(10); |
添加註釋 |
COMMENT ON COLUMN TABLE_NAME.COLUMN_NAME IS ‘註釋’; |
刪除字段 |
alter table TABLE_NAME drop column COLUMN_NAME; |
添加字段並附默認值 |
alter table TABLE_NAME ADD COLUMN_NAME NUMBER(1) DEFAULT 1; |
修改字段值 |
update TABLE_NAME set filedname=value where filedname=value; |
修改字段數據類型 |
alter table tablename modify filedname varchar2(20); |
修改字段默認值 |
alter table tablename modify filedname default 0; |
SELECT
*
FROM
(
SELECT
ID
FROM
table
)
WHERE
rownum = 1
rownum <= 10
- 標準sql規範
if a=.. then
......
elsif a=.. then
....
end if;
- decode函數
DECODE(value,if1,then1,if2,then2,if3,then3,...,else)
- case when
case when a='1'then 'xxxx'
when a='2' then 'ssss'
else
'zzzzz'
end as 別名