100分,乙個簡單的SQL語句,解釋一下

2025-02-04 04:00:28 字數 1207 閱讀 4680

1樓:水嘆花

set ansi_nulls on

當 set ansi_nulls 為 on 時,即使 column_name 中包含空值,使用 where column_name = null 的 select 語句仍返回零行。

go set quoted_identifier on

當 set quoted_identifier 為 on 時,識別符號可以由雙引號分隔,而文字必須由單引號分隔。

go if not exists (select * from where object_id = object_id(n'[dbo].[depart]')and type in (n'u'))

當已經存在表[depart]時候先刪除表[depart]

begin建表。create table [dbo].[depart](

departid] [int] identity(1,1) not null, -標識列從1開始遞增。

departname] [varchar](100) collate chinese_prc_ci_as null, -指定資料庫的預設排序規則chinese_prc_ci_as指標對大陸簡體字unicode的排序規則。

constraint [pk_depart] primary key clustered --為[departid]的公升序建立為主鍵。

departid] asc

with (ignore_dup_key = off) on [primary]

on [primary]

end go

2樓:

樓上的解釋有個錯誤。

if not exists(select * from where object_id = object_id(n'[dbo].[depart]')and type in (n'u'))

是指當不存豐表depart時才開始建立這張表,以begin開始到end結束。而不是你說的當已經存在表然後刪除表。雖然最後的結果一樣,但還是有區別的。

3樓:網友

者:水嘆花。

說的差不多了。

還有給lz乙個建議。不清楚的時候請你選中你不清楚的文字然後按:shift+f1

4樓:網友

你這些是不是自動生成的啊,裡面的那些名字根本看不明白,好象是儲存過程或其他的一些東東,你最好把完整的發來看看。

求SQL語句,求一個SQL語句

select from table name where 部門 工程部 and 經理簽字 0 and 行政簽字 0 and 結單 0 union all select from table name where 部門 工程部 and 經理簽字 1 and 行政簽字 0 and 結單 0 select...

求一個sql語句。求一個sql寫法

設 表1為mytable1 sl 分類求和後為sl1表2為mytable2 sl 分類求和後為sl2select from select lx sum sl sl1 from mytable1 group by lx a join select lx sum sl sl2 from mytable2...

SQL語句,請人幫下,一個SQL語句,請人幫下

select 表2.ming as 客戶姓名,表2.che as 車輛品牌 from 表1,表2 where 表1.xingming user and 表1.kehu 表2.ming select from 表2 where 表2.ming in select kehu from 表1 where ...