sqlserverupdate详细⽤法
UPDATE是我们常SQL语句之⼀,update主要⽤于更改表中的现有数据.
更新⼀个表:update product set l_parentid ='1'
详细解说: update 表名 set 列名 =参数
更新两个表或多个表: update product set l_parentid = producttype.parentid from product,producttype where product.l_typeid =producttype.id 详细解说: update 表名 set 列名 =参数 from 表名1,表名2 where 指定条件
UPDATE详细语法
{
table_name WITH ( < table_hint_limited > [ ...n ] )
| view_name
| rowset_function_limited
sql中update什么意思}
SET
{column_name = { expression | DEFAULT | NULL }
| @variable = expression
| @variable = column = expression } [ ,...n ]
{ { [ FROM { < table_source > } [ ,...n ] ]
[ WHERE
< search_condition > ] }
|
[ WHERE CURRENT OF
{ { [ GLOBAL ] cursor_name } | cursor_variable_name }
]
}
[ OPTION ( < query_hint > [ ,...n ] ) ]
< table_source > ::=
table_name [ [ AS ] table_alias ] [ WITH ( < table_hint > [ ,...n ] ) ]
| view_name [ [ AS ] table_alias ]
| rowset_function [ [ AS ] table_alias ]
| derived_table [ AS ] table_alias [ ( column_alias [ ,...n ] ) ]
| < joined_table >
< joined_table > ::=
< table_source > < join_type > < table_source > ON < search_condition >
| < table_source > CROSS JOIN < table_source >
| < joined_table >
< join_type > ::=
[ INNER | { { LEFT | RIGHT | FULL } [OUTER] } ]
[ < join_hint > ]
JOIN
< table_hint_limited > ::=
{ FASTFIRSTROW
| HOLDLOCK
| PAGLOCK
| READCOMMITTED
| REPEATABLEREAD
| ROWLOCK
| SERIALIZABLE
| TABLOCK
| TABLOCKX
| UPDLOCK
}
< table_hint > ::=
{ INDEX ( index_val [ ,...n ] )
| FASTFIRSTROW
| HOLDLOCK
| NOLOCK
| PAGLOCK
| READCOMMITTED
| READPAST
| READUNCOMMITTED
| REPEATABLEREAD
| ROWLOCK
| SERIALIZABLE
| TABLOCK
| TABLOCKX
| UPDLOCK
}
< query_hint > ::=
{ { HASH | ORDER } GROUP
| { CONCAT | HASH | MERGE } UNION
| {LOOP | MERGE | HASH } JOIN
| FAST number_rows
| FORCE ORDER
| MAXDOP
| ROBUST PLAN
| KEEP PLAN
}
参数
table_name
需要更新的表的名称。如果该表不在当前服务器或数据库中,或不为当前⽤户所有,这个名称可⽤链接服务器、数据库和所有者名称来限定。
SET
指定要更新的列或变量名称的列表。
⼩贴⼠:SQL Server 联机丛书就提供了很详细Transact-SQL 参考
update在⽤之前请你备份数据,在⽤的数据⼀更新错,你就挂了.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论