偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Sql server中如何刪除有默認(rèn)值的列

數(shù)據(jù)庫(kù) SQL Server
下面就將為您介紹Sql server中刪除有默認(rèn)值的列的方法,供您參考,希望能夠?qū)δ兴鶐椭?/div>

刪除列操作是在使用Sql server數(shù)據(jù)庫(kù)中比較常見(jiàn)的操作,但是如果刪除的列有默認(rèn)值,那應(yīng)該如何操作呢?下面就將為您介紹Sql server中刪除有默認(rèn)值的列的方法。

Access數(shù)據(jù)庫(kù)里可以直接用alter table article drop [列名]來(lái)刪隊(duì)列,但在Sql server數(shù)據(jù)庫(kù),如果這個(gè)列有默認(rèn)值,這樣刪除列會(huì)報(bào)錯(cuò),這時(shí)要?jiǎng)h除列的默認(rèn)值。

declare @name varchar(20)
select @name=b.name from syscolumns a,sysobjects b where a.id=object_id('[表名]') and b.id=a.cdefault and a.name='[列名]' and b.name like 'DF%'
exec('alter table article drop constraint '+@name)
alter table [表名] drop column [列名]

其它:
  刪除索引時(shí)Access為:drop index indexName on tableName
        sql 為:drop index tableName.indexName

  mssql給表添加主索引:alter table tablename add constraint [DF_tablename] default (1) for column

  建帶主索引表:create table tablename (id int identity(1,1) not null constraint PK_tablename primary key, column1 nvarchar(250) null)
 

責(zé)任編輯:段燃 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-10-22 16:56:35

sql server刪

2010-07-15 10:37:15

SQL Server默

2010-09-28 10:23:36

SQL修改字段

2010-09-07 16:05:23

SQL語(yǔ)句刪除

2010-09-28 10:35:58

SQL字段默認(rèn)值

2010-11-11 09:51:46

SQL Server添

2010-09-08 13:21:19

SQL刪除約束

2010-10-22 17:26:55

SQL Server刪

2012-08-01 09:50:11

交互設(shè)計(jì)UI設(shè)計(jì)

2010-11-12 15:28:59

sql server默

2010-09-28 15:24:43

sql語(yǔ)句

2010-09-02 11:14:39

SQL刪除日志

2009-04-20 15:54:04

SQL Server重復(fù)行

2009-07-02 12:30:00

標(biāo)識(shí)值SQL Server

2010-09-02 11:38:44

SQL刪除

2021-02-25 13:40:17

MySQL數(shù)據(jù)庫(kù)默認(rèn)值

2011-03-17 16:46:50

SQL Server存儲(chǔ)方式

2010-09-02 11:34:51

SQL刪除

2009-09-11 12:31:15

C# WinForm控設(shè)置默認(rèn)值

2010-07-08 13:06:05

SQL Server刪
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)