zoukankan      html  css  js  c++  java
  • Sql server 操作笔记

    (1)更改字段类型

    alter table mytable alter column mycol1 int default 0

    (2)添加字段

    alter table class add  InKinDate int
    EXECUTE sp_addextendedproperty N'MS_Description', N'新建班级年份,只存年', N'user', N'dbo', N'table', N'class', N'column', N'InKinDate'

     (3)查看当日[dd]、当月[mm]、当年[yy]的数据

    select * from askforleave where DateDiff(dd,createtime,getdate())=0

    (4)删除字段

    ALTER TABLE [表名] DROP COLUMN [字段名]

     (5)表及字段描述信息处理示例

    --为表添加描述信息
    EXECUTE sp_addextendedproperty N'MS_Description', '人员信息表', N'user', N'dbo', N'table', N'', NULL, NULL
    
    --为字段a1添加描述信息
    EXECUTE sp_addextendedproperty N'MS_Description', '姓名', N'user', N'dbo', N'table', N'', N'column', N'a1'
    
    --为字段a2添加描述信息
    EXECUTE sp_addextendedproperty N'MS_Description', '性别', N'user', N'dbo', N'table', N'', N'column', N'a2'
    
    --更新表中列a1的描述属性:
    EXEC sp_updateextendedproperty 'MS_Description','字段1','user',dbo,'table','','column',N'a1'
    
    --删除表中列a1的描述属性:
    EXEC sp_dropextendedproperty 'MS_Description','user',dbo,'table','','column',N'a1'

      

  • 相关阅读:
    gTest&gMock learning
    机器学习 delay learning
    c++ learning
    2017 湘潭邀请赛&JSCPC G&J
    mapreduce&GFS&bigtable learning
    golang learning
    高斩仙的北京历险记
    python learning
    Codeforces Round #448 (Div. 2) B
    python之callable
  • 原文地址:https://www.cnblogs.com/Zing/p/4580109.html
Copyright © 2011-2022 走看看