資料的操作(增刪改查)
1.插入資料:
(1)單行insert語句
insert into [表名] (欄位1,欄位2) values (100,'51windows.net')
(2)多行insert語句
insert into [表名] (欄位1,欄位2) select (欄位1,欄位2) from [表名2] where [條件]
2.刪除資料:
delete from [表名] where [欄位名]>100
更新資料:
update [表名] set [欄位1] = 200,[欄位2] = '51windows.net' where [欄位三] =
\'haiwa\'
3.查詢資料:
select (欄位1,欄位2) from [表名] where [條件] order by [字段] desc;
4.刪除表:
drop table [表名]
5.新增字段:
alter table [表名] add [欄位名] nvarchar (50) null
6.刪除字段:
alter table [表名] drop column [欄位名]
7.修改字段:
alter table [表名] alter column [欄位名] nvarchar (50) null
面試必須要知道的SQL語法,語句
隨機選擇資料庫記錄的方法 使用randomize函式,通過sql語句實現 對儲存在資料庫中的資料來說,隨機數特性能給出上面的效果,但它們可能太慢了些。你不能要求asp 找個隨機數 然後列印出來。實際上常見的解決方案是建立如下所示的迴圈 randomize rnumber int rnd 499 1 ...
面試必須要知道的SQL語法,語句
隨機選擇資料庫記錄的方法 使用randomize函式,通過sql語句實現 對儲存在資料庫中的資料來說,隨機數特性能給出上面的效果,但它們可能太慢了些。你不能要求asp 找個隨機數 然後列印出來。實際上常見的解決方案是建立如下所示的迴圈 randomize rnumber int rnd 499 1 ...
面試必須要知道的SQL語法,語句
面試必須要知道的sql語法,語句 posted 2007 06 18 23 00 編輯 收藏2007年6月16日 goto是各種規範中都保留的關鍵字,卻都不提倡使用的.有時可以用do.while.來代替goto do while 0 label1 dootherthing 這個相當於 if some...