alter場景
update場景1、建好表後增加外來鍵約束
alter
table 表名
addforeign
key(欄位名)
references 表名(欄位名)
2、新增字段
alter
table 表名
add 列名 資料格式
case場景update 表名
set 欄位名 = 更新後的值,可以公式表達
where 條件
as場景case 欄位名
when 某個值 then 表示式
when 某個值 then 表示式
else
end#別忘記最後的end
或者case
when 欄位名 = 某個值 then 表示式
when 欄位名 = 某個值 then 表示式
else
end
on場景1、建立表時直接從其他表獲取資料
create
table 表名 as
select 欄位名 from 表名
to場景1、建立索引
create
index 索引名稱 on 表名(欄位名)
2、建立觸發器
create
trigger 觸發器名稱 after
insert
/update
/delete
on 表名 #這裡的on表示針對那個表,與insert into
begin
insert
into audit values
(new.id,new.name)
;#注意末尾的分號,old和new分別表示在insert之前和之後的資料
end
1、插入資料
insert
into 表名
values
(第一行資料,各字段用逗號隔開)
,(第二行資料)
2、重新命名表
alter
table 表名 rename
to 新錶名
sql易錯點 和in區別
在阿根廷argentina及 澳大利亞australia所在的洲份中,列出當中的國家名字name及洲分continent。按國字名字順序排序 錯誤結果 select name,continent from world where continent in select continent from ...
面試易錯點
一 char str1 abc char str2 abc char str3 abc char str4 abc str1和str2是不相同的,str3和 str4是相同的,str1和str2是儲存在堆上,str3和 str4在常量區,這兩個指標指向的是同一位址 編譯器認為p1指向的 abc 和p...
總結 易錯點
題目要求是 結尾,我使用了str 1 str 2 single line containing only marks the end of a test case.題目給的是 f1 1 f2 2 fn fn 1 fn 2 n 3 我卻從f0開始推,並且迴圈跟著從0開始了 題目可能會出現一道腦筋急轉彎...