Set default value for column[转]

简介:
复制代码
1 
2    CREATE   TABLE  T (
3       int1  int ,
4       bit1  bit   NOT   NULL   DEFAULT   0 ,
5       rvr1  timestamp ,
6       usr1  nvarchar ( 28 DEFAULT   USER ,
7       createtime  datetime   DEFAULT   CURRENT_TIMESTAMP
8   )
9    GO
复制代码


复制代码
1 
2    INSERT  T (int1)  VALUES  ( 1 WAITFOR  DELAY  ' 00:00:01 '
3    GO
4    INSERT  T (int1, bit1)  VALUES  ( 2 0 WAITFOR  DELAY  ' 00:00:01 '
5    GO
6    INSERT  T (int1, bit1)  VALUES  ( 3 1 )
7    GO
复制代码

 

(1 rows affected)


1    SELECT  int1, bit1, usr1,
2        CONVERT ( int , rvr1)  ' Timestamp as int ' ,
3       createtime
4    FROM  T
5    GO


int1        bit1 usr1                         Timestamp as int createtime
----------- ---- ---------------------------- ---------------- -----------------------
          1    0 dbo                                      5007 2006-10-14 10:53:20.827
          2    0 dbo                                      5008 2006-10-14 10:53:21.827
          3    1 dbo                                      5009 2006-10-14 10:53:22.827

(3 rows affected)

 

1 
2    UPDATE  T
3    set  bit1  =   1
4    WHERE  int1  =   2
5    GO


(1 rows affected)

1    SELECT  int1, bit1, usr1,
2        CONVERT ( int , rvr1)  ' Timestamp as int ' ,
3       createtime
4    FROM  T
5    GO



int1        bit1 usr1                         Timestamp as int createtime
----------- ---- ---------------------------- ---------------- -----------------------
          1    0 dbo                                      5007 2006-10-14 10:53:20.827
          2    1 dbo                                      5010 2006-10-14 10:53:21.827
          3    1 dbo                                      5009 2006-10-14 10:53:22.827

(3 rows affected)

 

1 
2    drop   table  t
3    GO


from: 这里

欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,转载请注明出处!























本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/sunshine-anycall/archive/2010/05/23/1742354.html ,如需转载请自行联系原作者


相关文章
|
28天前
|
JSON Java 关系型数据库
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
在Java中,使用mybatis-plus更新实体类对象到mysql,其中一个字段对应数据库中json数据类型,更新时报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
41 4
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
成功解决A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,co
成功解决A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,co
|
4月前
|
Kubernetes Unix 容器
As the default settings are now deprecated, you should set the endpoint inste
As the default settings are now deprecated, you should set the endpoint inste
|
4月前
|
Java 应用服务中间件 nginx
【Azure 环境】Azure应用程序网关设置set_Cookie=key=value; SameSite=Strict; HTTPOnly,AzureAD登录使用cookie时使用不了的案例记录
【Azure 环境】Azure应用程序网关设置set_Cookie=key=value; SameSite=Strict; HTTPOnly,AzureAD登录使用cookie时使用不了的案例记录
|
5月前
|
数据处理 Python
【Python】已解决:SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFram
【Python】已解决:SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFram
742 1
content‘ is declared but its value is never read.富文本编辑器中这里必须的script中添加setup,引入到set当中时,带title的富文本写法
content‘ is declared but its value is never read.富文本编辑器中这里必须的script中添加setup,引入到set当中时,带title的富文本写法
|
6月前
|
缓存 NoSQL 关系型数据库
Redis第二课,1.set key value(设置对应的key和value)2.get key(得到value值)Redis全局命令(支持很多的数据结构)3.keys(用来查询当前
Redis第二课,1.set key value(设置对应的key和value)2.get key(得到value值)Redis全局命令(支持很多的数据结构)3.keys(用来查询当前
|
7月前
What value should kernel parameter AIO-MAX-NR be set to ?
What value should kernel parameter AIO-MAX-NR be set to ?
67 0
|
JavaScript API
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
390 0
|
7月前
|
druid Java
Error attempting to get column ‘createTime‘ from result set的异常
Error attempting to get column ‘createTime‘ from result set的异常
443 0