IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_SESSIONS') 
 CREATE TABLE T_BAS_SESSIONS (
FID VARCHAR(256) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME DEFAULT GETDATE(),
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FLANGUAGE VARCHAR(10) DEFAULT ' ' NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FUID BIGINT DEFAULT 0 NOT NULL,
FUSERNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FUSEROPENID VARCHAR(50) DEFAULT ' ' NOT NULL,
FUSERTYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FLOGINTIME DATETIME DEFAULT GETDATE() NOT NULL,
FLOGINIP VARCHAR(512) DEFAULT ' ' NOT NULL,
FYZJAPPID VARCHAR(50) DEFAULT ' ',
FYZJAPPTICKET VARCHAR(200) DEFAULT ' ',
FLOGINORG BIGINT DEFAULT 0 NOT NULL,
FCLIENT VARCHAR(10) DEFAULT ' ' NOT NULL,
FACCCOMPANYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FKDCSRFTOKEN VARCHAR(256) DEFAULT ' ' NOT NULL,
FAPI3RDAPPID VARCHAR(50) DEFAULT ' ' NOT NULL,
FAPI3RDAPPNUM VARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FEXPIREDTIME DATETIME DEFAULT GETDATE() 
);
EXEC P_ALTERPK 'PK_T_BAS_SESSIONS', 'T_BAS_SESSIONS', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'INDEX_T_BAS_SESSIONS_USER') CREATE INDEX INDEX_T_BAS_SESSIONS_USER ON T_BAS_SESSIONS ( FUSERID );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BAS_DEFAULT_PARAMS') 
 CREATE TABLE T_BAS_DEFAULT_PARAMS (
FID BIGINT DEFAULT 0 NOT NULL,
FPARAM_KEY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARAM_VALUE NVARCHAR(1024) DEFAULT ' ' NOT NULL,
FPARAM_TYPE NVARCHAR(10) DEFAULT ' ' NOT NULL
);

 EXEC P_ALTERPK 'PK_T_BAS_DEFAULT_PARAMS', 'T_BAS_DEFAULT_PARAMS', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_T_BAS_DEFAULT_PARAMS_DOU') CREATE INDEX IDX_T_BAS_DEFAULT_PARAMS_DOU ON T_BAS_DEFAULT_PARAMS ( FPARAM_TYPE ,FPARAM_KEY );