SQL 基础语句【表、约束、索引】
表专区
--
复制表及数据(从
userinfo
表复制到新表
b
select
*
into
b
from
UserInfo
--
获取当前数据库中的所有用户表
select * from sysobjects where xtype='U' and category=0
--
获取某一个表的所有字段
select name from syscolumns where id=object_id('表名')
约束专区
--
查询表
约束
exec
sp_helpconstraint
表名
--
添加外键约束
alter
table
表名
add
constraint
外键名
foreign
key
(
引用列名
)
references
被引用表名
(
列名
)
索引专区
----查找表中的索引
select
*
from
sysindexes
where
id
=
object_id
(
'
表名
'
)
exec
sp_helpindex
g_Account
-----
判断是否存在索引
select
*
from
sysindexes
where
name
=
'索引名
'
--创建索引
CREATE UNIQUE INDEX 索引名称
ON 表名称
(
列名称
)
相关文档:
if object_id('[tb]') is not null
drop table [tb]
go
create table [tb]([id] int,[col1] varchar(8),[col2] int)
insert [tb]
select 1,'河北省',0 union all
select 2,'邢台市',1 union all
select 3,'石家庄市',1 union all
select 4,'张家口市',1 union all
&n ......
5.1 密码策略
由于sql server不能更改sa用户名称,也不能删除这个超级用户,所以,我们必须对这个帐号进行最强的保护,当然,包括使用一个非常强壮的密码,最好不要在数据库应用中使用sa帐号。新建立一个拥有与sa一样权限的超级用户来管理数据库。同时养成定期修改密码的好习惯。数据库管理员应该定期查看是否有不符合 ......
1.oracle
sql = "SELECT column_name, data_type, data_length, nullable";
sql += " from user_tab_columns ";
sql += " where table_name='";
sql += $tableName;
sql += "'";
select * from user_tab_comments & ......
网站:http://werysoft.com/
如果您必须管理环境中的多种类型的数据库服务器,则使用集中式工具调整所有数据库可能会比较方便。Werysoft 的 QweryBuilder 旨在为您提供此项功能。您可以使用它从同一 GUI 连接到 Microsoft SQL Server、Sybase ASE、SQL Anywhere 和 Oracle 实例,然后查看、创建、更新和删除数据库脚本、架 ......
http://weblogs.asp.net/scottgu/archive/2007/09/07/linq-to-sql-part-9-using-a-custom-linq-expression-with-the-lt-asp-linqdatasource-gt-control.aspx
1-9 parts are the most useful knowledge for you so far. ......