sql 修改列名及表名
代码如下:
EXEC sp_rename '表名.[原列名]', '新列名', 'column'
*************************************************************************
Transact-SQL 参考
sp_rename
更改当前数据库中用户创建对象(如表、列或用户定义数据类型)的名称。
示例
A. 重命名表
下例将表 customers 重命名为 custs。
EXEC sp_rename 'customers', 'custs'
B. 重命名列
下例将表 customers 中的列 contact title 重命名为 title。
EXEC sp_rename 'customers.[contact title]', 'title', 'COLUMN'
***********
而修改数据库名则用
sp_renamedb [ @dbname = ] 'old_name' , [ @newname = ] 'new_name'
相关文档:
--1加内存表
EXEC sp_tableoption '表名','pintable', 'true'
--2卸载内存表
EXEC sp_tableoption '表名','pintable', 'false'
--2查询是否有内存表驻留
SELECT * from INFORMATION_SCHEMA.Tables
WHERE TABLE_TYPE = 'BASE TABLE'
AND OBJECTPROP ......
PairWise subquery:
e.g.:
select * from wf_docsort where (ndocsortid,nmoduleinfoid) in (select ndocsortid, nmoduleinfoid from wf_docsort where instr(cname,'文')>0)
the above sql is the same function as:
select * from wf_docsort where ndocsortid = (select ndocsortid from wf_docsort where ......
oracle tips
Exist的用法:
select gw.ndocid from
(select ndocid from wf_doc_gw_shouwen union select ndocid from wf_doc_gw_fawen) gw
where
not exists (select null from wf_doc_gw_sn sn where sn.ndocid=gw.ndocid)
2。把GW表和SN表里相同的NDOCID显示出来
select gw.ndocid from
(se ......
以前一直觉得linq to sql生成类似where id not in (1,3,5)或where id not in (select id from ...)这样的条件不是很方便,每次我都是把条件ID事先取到一个数组里,然后用 !Arr.Contains(c.Id)这样处理,今天突然发现这样好傻,其实可以完全直接用linq写成一句,贴个示例在这里,以后备查
from a in TableA where !(fr ......
---附加数据库
sp_attach_db '数据库名','数据库全路径','数据库日志全路径'
---查看数据库逻辑文件名
RESTORE FILELISTONLY from disk = '备份文件'
---还原数据库
restore database hzrb from disk = '备份文件'
with move '主逻辑名' to '存放mdf路径' ......