package com.sql.util;
|
|
import java.sql.SQLException;
|
import java.util.Date;
|
|
import com.base.Com;
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class Db_Work {
|
public static void init(MysqlConnPool pool) {
|
System.out.println("Db_Work init Start " + Com.getDateTimeFormat(new Date(),Com.DTF_YMDhms));
|
|
createDb_Work(pool);
|
|
createWorksheet_Link_Table(pool);
|
|
createWorksheet_Main_Table(pool);
|
|
System.out.println("Db_Work init End " + Com.getDateTimeFormat(new Date(),Com.DTF_YMDhms));
|
}
|
|
|
public static void createDb_Work(MysqlConnPool pool) {
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute("CREATE SCHEMA IF NOT EXISTS " + Sql_Mysql.DB_WORK + " AUTHORIZATION sysdba");
|
} catch (SQLException e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* ´´½¨ db_work.worksheet_link Êý¾Ý¿â±í
|
* @param conn
|
*/
|
public static void createWorksheet_Link_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Worksheet_Link_Table + "_auto" +
|
" INCREMENT 1" +
|
" MINVALUE 1" +
|
" MAXVALUE 9223372036854775807" +
|
" START 1" +
|
" CACHE 1;";
|
//´´½¨×ÔÔöÐòÁÐ
|
sql.sqlMysqlExecute(sql_str_auto);
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Worksheet_Link_Table + " "
|
+ "(id integer NOT NULL DEFAULT nextval('" + Sql_Mysql.Worksheet_Link_Table + "_auto'::regclass)," +
|
" main_id integer," +
|
" parent_id integer," +
|
" deal_user_id integer," +
|
" deal_type integer," +
|
" deal_desc character varying(255) COLLATE pg_catalog.\"default\" DEFAULT NULL::character varying," +
|
" deal_reason character varying(255) COLLATE pg_catalog.\"default\" DEFAULT NULL::character varying," +
|
" link_file character varying(255) COLLATE pg_catalog.\"default\" DEFAULT NULL::character varying," +
|
" link_status integer," +
|
" enable_archive integer," +
|
" create_time timestamp without time zone NOT NULL," +
|
" deal_time timestamp without time zone NOT NULL," +
|
" PRIMARY KEY (id)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Worksheet_Link_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".id IS 'Ö÷¼üid';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".main_id IS 'Ö÷±íid';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".parent_id IS '¸¸½Úµãid';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".deal_user_id IS '´¦ÀíÈËid';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".deal_type IS '´¦ÀíÀàÐÍ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".deal_desc IS '´¦ÀíÃèÊö';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".deal_reason IS '´¦ÀíÒâ¼û';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".link_file IS '½Úµã¸½¼þµÄÎļþ·¾¶';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".link_status IS '½Úµã״̬';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".enable_archive IS 'ÄÜ·ñ¹éµµ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".create_time IS '½Úµã´´½¨Ê±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Link_Table + ".deal_time IS '½Úµã´¦Àíʱ¼ä';");
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
|
/**
|
* ´´½¨ db_work.worksheet_main Êý¾Ý¿â±í
|
* @param conn
|
*/
|
public static void createWorksheet_Main_Table(MysqlConnPool pool)
|
{
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
String sql_str_auto = "CREATE SEQUENCE IF NOT EXISTS " + Sql_Mysql.Worksheet_Main_Table + "_auto" +
|
" INCREMENT 1" +
|
" MINVALUE 1" +
|
" MAXVALUE 9223372036854775807" +
|
" START 1" +
|
" CACHE 1;";
|
//´´½¨×ÔÔöÐòÁÐ
|
sql.sqlMysqlExecute(sql_str_auto);
|
|
String sql_str = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Worksheet_Main_Table + " "
|
+ "(id integer NOT NULL DEFAULT nextval('" + Sql_Mysql.Worksheet_Main_Table + "_auto'::regclass)," +
|
" title character varying(255) NOT NULL COLLATE pg_catalog.\"default\"," +
|
" description character varying(255) COLLATE pg_catalog.\"default\" DEFAULT NULL::character varying," +
|
" file character varying(255) COLLATE pg_catalog.\"default\" DEFAULT NULL::character varying," +
|
" create_user_id integer NOT NULL," +
|
" begin_time timestamp without time zone NOT NULL," +
|
" end_time timestamp without time zone NOT NULL," +
|
" level integer," +
|
" status integer," +
|
" end_reason integer," +
|
" type integer," +
|
" PRIMARY KEY (id)" +
|
")";
|
sql.sqlMysqlExecute(sql_str);
|
|
sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Worksheet_Main_Table + " OWNER TO sysdba;");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".id IS 'Ö÷¼üid';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".title IS '¹¤µ¥±êÌâ';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".description IS 'ÈÎÎñÃèÊö';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".create_user_id IS '¹¤µ¥´´½¨ÈËid';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".begin_time IS '¹¤µ¥¿ªÊ¼Ê±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".end_time IS '¹¤µ¥½áÊøÊ±¼ä';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".level IS '¹¤µ¥¼¶±ð';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".status IS '¹¤µ¥×´Ì¬';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".end_reason IS '¹¤µ¥½áÊøÒâ¼û';");
|
sql.sqlMysqlExecute("COMMENT ON COLUMN " + Sql_Mysql.Worksheet_Main_Table + ".type IS '¹¤µ¥ÀàÐÍ';");
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
}
|