使用模板创建的数据库设计文档模板中有哪些对象?

SQL在创建数据库时,系统自动将系统数据库中的所有用户定义的对象都复制到( )l的数据库中。_百度知道
SQL在创建数据库时,系统自动将系统数据库中的所有用户定义的对象都复制到( )l的数据库中。
)是填MODEL还是填MASTER,急速回!
提问者采纳
可以确定吗
来自团队:
其他类似问题
为您推荐:
其他3条回答
复制到(新)的数据库中。书中课后练习题原话。P56
创建数据库的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁数据库中起到模板作用的数据库有哪些?_百度知道
数据库中起到模板作用的数据库有哪些?
提问者采纳
tempdb,分别是、modle:master,系统数据库有四个SQL Server 中
提问者评价
其他类似问题
为您推荐:
数据库的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁An error occurred.
Sorry, the page you are looking for is currently unavailable.
Please try again later.
If you are the system administrator of this resource then you should check
for details.
Faithfully yours, nginx.1 &#@ template debug="false" hostspecific="false" language="C#" #&
2 &#@ output extension=".cs" #&
3 &#@ assembly name="System.Data" #&
4 &#@ assembly name="System.Xml" #&
5 &#@ import namespace="System" #&
6 &#@ import namespace="System.Xml" #&
7 &#@ import namespace="System.Data" #&
8 &#@ import namespace="System.Data.SqlClient" #&
10 ModelManager manager = new ModelManager();
11 string tableName = "tbOptAuthor";
12 DataTable table= manager.GetTableSchema(tableName);
14 /* ****************************************************************************************
* 版权所有:西安xxx软件有限公司
途:数据传输对象(DTO)
* 结构组成:
者:王光旭
* 创建日期:&#=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")#&
* 历史记录:
* ****************************************************************************************
* 修改人员:
* 修改日期:
* 修改说明:
* ****************************************************************************************/
26 using S
27 using System.Collections.G
28 using System.L
29 using System.T
31 namespace wgx.Model
[Serializable]
/// &summary&
/// &#= tableName.Replace("tb","DTO_") #&
/// &/summary&
public class &#= tableName.Replace("tb","DTO_") #&
#region 属性
foreach(DataRow row in table.Rows)
/// &summary&
/// &#=row["Description"]#&
/// &/summary&
public &#= manager.TransFromSqlType(row["DataType"].ToString(),row["IsNullable"].ToString())#&
&#=row["ColumnName"]#&{ get; set; }
#endregion
public class ModelManager
/// &summary&
/// 数据库连接字符串
/// &/summary&
private const string CONNECTION_STRING="Data Source=.;Initial Catalog=User ID=pwd=000000";
/// &summary&
/// 用户信息表名
/// &/summary&
private const string PERSONINFO_TABLE_NAME = "tbOptAuthor";
/// &summary&
/// 根据表名查询表结构信息
/// SQL Server 2005写法
/// &/summary&
private const string SELECT_SCHEMA_BY_TABLE_NAMEs = @"SELECT
d.name AS TableName,
a.colorder AS ColumnID,
a.name AS ColumnName,
b.name AS DataType,
g.[value] AS Description,
CASE WHEN a.isnullable = 0 THEN 'false'
ELSE 'true'
END AS IsNullable
FROM syscolumns a left join systypes b
on a.xtype=b.xusertype
inner join sysobjects d
on a.id=d.id and d.xtype='U' and d.name&&'dtproperties'
left join sys.extended_properties g
on a.id=g.major_id AND a.colid = g.minor_id
WHERE d.[name] ='{0}'
order by a.id,a.colorder";
/// &summary&
/// 根据表名查询表结构信息
/// SQL Server 2000写法
/// &/summary&
private const string SELECT_SCHEMA_BY_TABLE_NAME = @"SELECT (
case when a.colorder=1 then d.name else '' end) N'表名',
a.colorder N'字段序号',a.name N'ColumnName',
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '&'else '' end) N'标识',
(case when (SELECT count(*) FROM sysobjects
WHERE (name in (SELECT name FROM sysindexes
WHERE (id = a.id) AND (indid in
(SELECT indid FROM sysindexkeys
WHERE (id = a.id) AND (colid in
(SELECT colid FROM syscolumns
WHERE (id = a.id) AND (name = a.name))))))) AND
(xtype = 'PK'))&0 then '&' else '' end) N'主键',b.name N'DataType',a.length N'占用字节数',
COLUMNPROPERTY(a.id,a.name,'PRECISION') as N'长度',isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0) as N'小数位数',
(case when a.isnullable=1 then '&'else '' end) N'IsNullable',
isnull(e.text,'') N'默认值',isnull(g.[value],'') AS N'Description'
--into ##tx
FROM syscolumns a left join systypes b on a.xtype=b.xusertype
inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name&&'dtproperties'
left join syscomments e on a.cdefault=e.id
left join sysproperties g on a.id=g.id AND a.colid = g.smallid
where d.name='{0}'
order by object_name(a.id),a.colorder";
/// &summary&
/// 获得数据连接
/// &/summary&
/// &returns&&/returns&
private SqlConnection GetConnection()
return new SqlConnection(CONNECTION_STRING);
/// &summary&
/// 释放连接
/// &/summary&
/// &param name="con"&&/param&
private void ReleaseConnection(SqlConnection con)
if (con != null)
if (con.State == ConnectionState.Open)
con.Close();
/// &summary&
/// &/summary&
/// &param name="tableName"&&/param&
public DataTable GetTableSchema(string tableName)
using (SqlConnection con = GetConnection())
con.Open();
SqlCommand cmd = con.CreateCommand();
mandText = string.Format(SELECT_SCHEMA_BY_TABLE_NAME,tableName);
mandType = CommandType.T
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
dt = ds.Tables[0];
/// &summary&
/// &/summary&
public void Generate()
DataTable table = GetTableSchema(PERSONINFO_TABLE_NAME);
if (table != null && table.Rows.Count & 0)
foreach (DataRow row in table.Rows)
Console.WriteLine("public class {0}", row["TableName"]);
Console.WriteLine("public {0} {1}", TransFromSqlType(row["DataType"].ToString(),row["IsNullable"].ToString()), row["ColumnName"]);
/// &summary&
/// &/summary&
/// &param name="type"&&/param&
/// &returns&&/returns&
public string TransFromSqlType(string type,string isNull)
string typeStr="";
switch (type)
//数据库的数据类型转换为对应的C#的数据类型,不是很完整
case "datetime":
case "smalldatetime":
typeStr=isNull=="true"? "?":"";
return "DateTime"+typeS
case "int":
case "smallint":
typeStr=isNull=="true"? "?":"";
return "int"+typeS
case "bit":
typeStr=isNull=="true"? "?":"";
return "bool"+typeS
case "float":
typeStr=isNull=="true"? "?":"";
return "double"+typeS
case "decimal":
case "money":
case "smallmoney":
case "numeric":
typeStr=isNull=="true"? "?":"";
return "decimal"+typeS
case "uniqueidentifier":
typeStr=isNull=="true"? "?":"";
return "Guid"+typeS
return "string"+typeS
生成后的实体:
1 /* ****************************************************************************************
* 版权所有:西安xxx软件有限公司
途:数据传输对象(DTO)
* 结构组成:
者:王光旭
* 创建日期: 11:32:47
* 历史记录:
* ****************************************************************************************
* 修改人员:wgx
* 修改日期: 11:32:47
* 修改说明:新增一个针对sql 2000数据库的查询方法
* ****************************************************************************************/
13 using S
14 using System.Collections.G
15 using System.L
16 using System.T
18 namespace wgx.Model
[Serializable]
/// &summary&
/// DTO_OptAuthor
/// &/summary&
public class DTO_OptAuthor
#region 属性
/// &summary&
/// 用户组代码
/// &/summary&
public string
strGroupCode{ get; set; }
/// &summary&
/// 功能模块代码
/// &/summary&
public string
strCaseCode{ get; set; }
/// &summary&
/// 权限级别
/// &/summary&
public string
strLevel{ get; set; }
/// &summary&
/// 组数据级别
/// &/summary&
public string
strGroupLevel{ get; set; }
#endregion
阅读(...) 评论()}

我要回帖

更多关于 使用文件组创建数据库 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信