一些簡單的SQL語句結構

2022-06-09 21:18:11 字數 523 閱讀 7315

筆試裡除了複雜一些的select語句,也會有一些update等語句,從w3school看了一下,總結一下:

insert語句

語法:insert into table_name (列1, 列2,...) values (值1, 值2,....)

例項:insert into persons (lastname, address) values ('wilson', 'champs-elysees')

update語句

語法:update 表名稱 set 列名稱 = 新值 where 列名稱 = 某值

例項:update person set address = 'zhongshan 23', city = 'nanjing' where lastname = 'wilson'

delete語句:

語法:delete from 表名稱 where 列名稱 = 值

例項:delete from person where lastname = 'wilson'

sql一些簡單的查詢語句

1.查詢今天的資料 select from 函式名 字段,getdate 2.查詢昨天的資料 select from 函式名 字段,dateadd day,1,getdate 3.查詢前天的資料 select from 函式名 字段,dateadd day,2,getdate 4.查詢本月的資料 d...

一些sql語句

一。在oracle中建表,怎麼實現id自動編號 1 建表 create table code test id int,name varchar2 20 2.建立序列 create sequence s country id increment by 1 start with 1 maxvalue 9...

一些Sql語句

case when xx then yy else zz 例 case when count is null then 0 else count 當count為空的時候賦值0,不為空則取原值 isnull express1,express2 例 isnull count,0 當count為空的時候則...