SQl语句修改和查看数据表的基本语句
2014-11-30 15:49
399 查看
--添加字段 alter table GSP_MHJ alter add Salequantity money
--删除字段 ALTER TABLE Files DROP COLUMN imgFile --修改字段属性 alter table GSP_MHJ alter column Salequantity money alter table GSP_MHJ alter column Salequantity money not null; --修改字段名: alter table tab_info rename column createname to thisname; --修改默认值 alter table tabinfo add constraint df default('嘿嘿') for thisname; --添加说明 EXECUTE sp_addextendedproperty N'MS_Description', '描述内容', N'user', N'dbo', N'table', N'表名', NULL, NULL EXECUTE sp_addextendedproperty N'MS_Description', '描述内容', N'user', N'dbo', N'table', N'Products', N'column', N'列名' --修改说明 EXECUTE sp_updateextendedproperty N'MS_Description', '描述内容', N'user', N'dbo', N'table', N'表名', NULL, NULL EXECUTE sp_updateextendedproperty N'MS_Description', '描述内容', N'user', N'dbo', N'table', N'Products', N'column', N'列名' --获取表中所有字段的说明,并且<>'' --g.[value]<>'' SELECT a.name FiledName,g.[value] AS Notes FROM syscolumns a left join systypes b on a.xtype=b.xusertype inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' left join sys.extended_properties g on a.id=g.major_id AND a.colid = g.minor_id WHERE d.[name] ='表名' and g.[value]<>'' order by a.id,a.colorder<pre name="code" class="sql">
--创建唯一性约束 alter table UnitTypes add constraint OrderID_only unique (OrderID) alter table 表名 add constraint 约束名 unique (列名[也可称为字段])
相关文章推荐
- 在VB.NET中 用代码 利用SQL语句创建数据库、表、存储过程、视图、索引、规则、修改表、查看数据等的方法
- 基本查询语句及利用SQL语句完成数据的添加、删除、修改操作
- SQL基本操作 - 新增、查看、修改、删除数据表
- [转]方便查看数据表和字段的SQL语句(适用于SQLServer2000)
- 在修改数据的SQL语句中使用OUTPUT子句带来的好处
- 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等
- 利用修改AccessDataSource的sql语句来检索数据
- 查看oracle中哪些SQL语句在执行和给定表空间数据量增长
- 根据基本表结构及其数据生成SQL语句
- sql语句修改access中的字段类型,access数据类型大全!
- SQL语句大全—查看数据(三)
- 用SQL语句添加删除修改字段及一些表与字段的基本操作 .
- 掌握SQL四条最基本的数据操作语句:Insert,Select,Update和Delete
- 根据基本表结构及其数据生成INSERT 语句的SQL脚本
- SQL语句大全—查看数据表(四)
- SQL根据一个表的数据修改另一表数据的语句
- 用SQL语句修改MSSQL数据库表字段的默认值(downmoon)
- SQL语句大全—查看数据(三)
- 掌握SQL四条最基本的数据操作语句:Insert,Select,Update和Delete
- 利用修改AccessDataSource的sql语句来检索数据