DT 的数据字典
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.7 KiB

1 year ago
<%@ CodeTemplate Language="C#" ClassName="TableInfoSqlEx" TargetLanguage="C#" Debug="False" Description="" encoding="UTF��8" %>
<%@ Property Name="databaseProjectName" Type="System.String" Default="SpSampleDb" Optional="True" Category="Context" Description="" %>
<%@ Property Name="nameSpace" Type="System.String" Default="sql" Optional="True" Category="Context" Description="" %>
/*******************************************************/
/*Create table */
/*******************************************************/
<%
DbEntity db = Template.GetDataBase(databaseProjectName);
foreach(Table tb in db.Tables)
{
OpenResponse(databaseProjectName+"\\TableInfoSql\\"+tb.ModuleName+"\\"+tb.Name+"Ex.sql");
string pkParmList = "";
foreach(Field fd in tb.Fields)
{
if(fd.IsPK == true)
pkParmList += fd.DataType.DotNetType+" "+fd.MemberName+",";
}
pkParmList = pkParmList.Trim(',');
string tablename=tb.TableSpace.ToLower() +tb.MemberName.ToLower();
%>
alter table <%=tablename%> add createdate datetime;
alter table <%=tablename%> add createuserid varchar(50);
alter table <%=tablename%> add createusername varchar(50);
alter table <%=tablename%> add modifydate datetime;
alter table <%=tablename%> add modifyuserid varchar(50);
alter table <%=tablename%> add modifyusername varchar(50);
alter table <%=tablename%> add PartOrg varchar(50);
go
/* View*/
alter View V_<%=tablename%>
as
select * from <%=tablename%>;
go
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','createdate','datetime','50','0','0','False','','<%="\u521b\u5efa\u65f6\u95f4"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','createuserid','varchar','50','0','0','False','','CreateUserId');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','createusername','varchar','50','0','0','False','','<%="\u521b\u5efa\u4eba"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','modifydate','datetime','50','0','0','False','','<%="\u4fee\u6539\u65f6\u95f4"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','modifyuserid','varchar','50','0','0','False','','ModifyUserId');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','modifyusername','VarChar','50','0','0','False','','<%="\u4fee\u6539\u4eba"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','partorg','varchar','50','0','0','False','','PartOrg');
stop-----/* add default */
go
alter table <%=tablename%> add IntVal1 int ;
alter table <%=tablename%> add CDefine1 varchar(50);
alter table <%=tablename%> add CDefine2 varchar(50);
go
alter View V_<%=tablename%>
as
select * from <%=tablename%>;
go
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','IntVal1','int','8','0','0','False','','<%="\u5907\u7528"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','CDefine1','varchar','50','0','0','False','','<%="\u5907\u7528"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','CDefine2','varchar','50','0','0','False','','<%="\u5907\u7528"%>');
stop-----/* add default2 */
alter table <%=tablename%> add IntVal2 int ;
alter table <%=tablename%> add IntVal3 int ;
alter table <%=tablename%> add CDefine3 varchar(50);
go
/* View*/
alter View V_<%=tablename%>
as
select * from <%=tablename%>;
go
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','IntVal2','int','8','0','0','False','','<%="\u5907\u75282"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','IntVal3','int','8','0','0','False','','<%="\u5907\u75283"%>');
insert into cb_TableField (tablename,fieldname,datatype,fieldlength,fieldidentity,fieldkey,notnullable,defaults,remark) values(
'<%=tablename%>','CDefine3','varchar','50','0','0','False','','<%="\u5907\u7528"%>');
<%
CloseResponse();
}
%>