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.

114 lines
3.1 KiB

1 year ago
<%@ CodeTemplate Language="C#" ClassName="TableSQLJava" TargetLanguage="C#" Debug="False" Description="" encoding="GB2312" %>
<%@ 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);
//OpenResponse(databaseProjectName+"\\databasejavacloud.sql");
foreach(string modulename in db.ModuleNames)
{
OpenResponse(databaseProjectName+"\\"+modulename+".sql");
foreach(Table tb in db.Tables)
{
if(modulename!=tb.ModuleName){
continue;
}
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();
Response.WriteLine("-- ----------------------------");
Response.WriteLine("-- " + tb.CnName+" " );
Response.WriteLine("-- ----------------------------");
Response.Write("DROP TABLE IF EXISTS ");
Response.Write(tablename);
Response.WriteLine(";");
Response.WriteLine("create table " + tablename+" (" );
int icount=0;
foreach(Field fd in tb.Fields)
{
string filename=fd.MemberName.ToLower();
Response.Write(" "+ filename+" "+ fd.DataType.FullName );
if(fd.Identity.ToString()!=""){
Response.Write( " auto_increment primary key" );
}else{
if(fd.IsPK == true){
Response.Write( " primary key " );
}}
if(fd.DefaultValue != ""){
Response.Write( " default '"+fd.DefaultValue+"' " );
}
if(fd.IsNullable == true){
Response.Write( " null " );
}else{
Response.Write( " not null " );
}
Response.Write( " COMMENT '" );
Response.Write( fd.CnName);
Response.Write( "' " );
Response.WriteLine(" ," );
icount++;
}
%>
create_by VarChar(50) null COMMENT '<%="\u521b\u5efa\u4eba"%>' ,
create_time datetime null COMMENT '<%="\u521b\u5efa\u65f6\u95f4"%>' ,
update_by VarChar(50) null COMMENT '<%="\u4fee\u6539\u4eba"%>' ,
update_time datetime null COMMENT '<%="\u4fee\u6539\u65f6\u95f4"%>' ,
field1 VarChar(50) null COMMENT '<%="\u5907\u7528"%>1' ,
field2 VarChar(50) null COMMENT '<%="\u5907\u7528"%>2' ,
field3 VarChar(50) null COMMENT '<%="\u5907\u7528"%>3' ,
<%
if(icount>15){
%>
field2 VarChar(50) null COMMENT '<%="\u5907\u7528"%>4' ,
<%
}
%>
<%
if(icount>20){
%>
field2 VarChar(50) null COMMENT '<%="\u5907\u7528"%>5' ,
<%
}%>
sys_area_code VarChar(50) null COMMENT '<%="\u6240\u5c5e\u533a\u57df"%>' ,
sys_unit_code VarChar(50) null COMMENT '<%="\u6240\u5c5e\u5355\u4f4d"%>' ,
sys_org_code VarChar(50) null COMMENT '<%="\u6240\u5c5e\u90e8\u95e8"%>'
) COMMENT '<%= tb.CnName%>' ;
<%
}
CloseResponse();
}
%>