PostgreSQL 建库建表脚本

时间:2021-11-22 08:40:14

1.创建角色(create_role.sql)

drop role if exists "kq_acs";
create role "kq_acs" login encrypted password 'kq_acs' inherit connection limit -1;

2.创建数据库(create_db.sql )  ps:要创建的数据库不存在

CREATE DATABASE "kq_acs" WITH OWNER = kq_acs ENCODING = 'UTF8';

3.创建表结构(create_tables.sql)

/*
Navicat PGSQL Data Transfer

Source Server         : 10.0.2.138
Source Server Version : 90309
Source Host           : 10.0.2.138:5432
Source Database       : acs
Source Schema         : public

Target Server Type    : PGSQL
Target Server Version : 90309
File Encoding         : 65001

Date: 2017-10-16 18:25:28
*/


-- ----------------------------
-- Sequence structure for hibernate_sequence
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."hibernate_sequence";
CREATE SEQUENCE "public"."hibernate_sequence"
 INCREMENT 1
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START 1
 CACHE 1;

-- ----------------------------
-- Table structure for kq_acs
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_acs";
CREATE TABLE "public"."kq_acs" (
"acs_id" varchar(32) COLLATE "default" NOT NULL,
"create_time" varchar(50) COLLATE "default" NOT NULL,
"emp_id" varchar(32) COLLATE "default" NOT NULL,
"company_id" varchar(32) COLLATE "default",
"dept_id" varchar(32) COLLATE "default",
"latitude" varchar(20) COLLATE "default",
"longitude" varchar(20) COLLATE "default",
"acs_name" varchar(50) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_admin
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_admin";
CREATE TABLE "public"."kq_admin" (
"admin_id" varchar(32) COLLATE "default" NOT NULL,
"admin_pid" varchar(30) COLLATE "default" NOT NULL,
"admin_pwd" varchar(32) COLLATE "default" NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_asuq
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_asuq";
CREATE TABLE "public"."kq_asuq" (
"asuq_id" varchar(32) COLLATE "default" NOT NULL,
"uuid" varchar(100) COLLATE "default" NOT NULL,
"emp_number" varchar(20) COLLATE "default" NOT NULL,
"emp_id" varchar(32) COLLATE "default" NOT NULL,
"company_id" varchar(32) COLLATE "default" NOT NULL,
"dept_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_auth
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_auth";
CREATE TABLE "public"."kq_auth" (
"auth_id" varchar(50) COLLATE "default" NOT NULL,
"auth_list" varchar(1000) COLLATE "default",
"purview" varchar(50) COLLATE "default",
"emp_id" varchar(50) COLLATE "default" NOT NULL,
"company_id" varchar(50) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_dept
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_dept";
CREATE TABLE "public"."kq_dept" (
"dept_id" varchar(32) COLLATE "default" NOT NULL,
"dept_num" varchar(20) COLLATE "default" NOT NULL,
"dept_name" varchar(20) COLLATE "default" NOT NULL,
"company_id" varchar(32) COLLATE "default",
"set_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_emp
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_emp";
CREATE TABLE "public"."kq_emp" (
"emp_id" varchar(32) COLLATE "default" NOT NULL,
"emp_number" varchar(20) COLLATE "default" NOT NULL,
"emp_name" varchar(30) COLLATE "default" NOT NULL,
"phone" varchar(12) COLLATE "default" NOT NULL,
"email" varchar(30) COLLATE "default",
"hasmod" int4 NOT NULL,
"head_img" varchar(300) COLLATE "default",
"gender" varchar(8) COLLATE "default",
"age" int4,
"register_code" varchar(32) COLLATE "default",
"temp_key" varchar(32) COLLATE "default",
"limit_time" varchar(32) COLLATE "default",
"temp_code" varchar(32) COLLATE "default",
"temp_code_limit" varchar(32) COLLATE "default",
"mac_name" varchar(40) COLLATE "default",
"dept_id" varchar(32) COLLATE "default",
"company_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_employ
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_employ";
CREATE TABLE "public"."kq_employ" (
"ephone" varchar(50) COLLATE "default" NOT NULL,
"epwd" varchar(50) COLLATE "default" NOT NULL,
"epid" varchar(50) COLLATE "default" NOT NULL,
"speaker_id" varchar(50) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_feedback
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_feedback";
CREATE TABLE "public"."kq_feedback" (
"feedback_id" varchar(32) COLLATE "default" NOT NULL,
"feedbackinfo" text COLLATE "default" NOT NULL,
"create_time" char(50) COLLATE "default" NOT NULL,
"phone" varchar(50) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_leave
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_leave";
CREATE TABLE "public"."kq_leave" (
"leave_id" varchar(32) COLLATE "default" NOT NULL,
"leave_type" varchar(10) COLLATE "default" NOT NULL,
"start_time" varchar(50) COLLATE "default" NOT NULL,
"end_time" varchar(50) COLLATE "default",
"create_time" varchar(50) COLLATE "default" NOT NULL,
"leave_content" varchar(100) COLLATE "default" NOT NULL,
"approval_name" varchar(40) COLLATE "default" NOT NULL,
"emp_id" varchar(32) COLLATE "default",
"company_id" varchar(32) COLLATE "default",
"dept_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_loc
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_loc";
CREATE TABLE "public"."kq_loc" (
"loc_id" int4 NOT NULL,
"loc_time" varchar(30) COLLATE "default",
"latitude" varchar(20) COLLATE "default",
"longitude" varchar(20) COLLATE "default",
"emp_number" varchar(32) COLLATE "default",
"company_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_lock
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_lock";
CREATE TABLE "public"."kq_lock" (
"lock_id" varchar(32) COLLATE "default" NOT NULL,
"lock_name" varchar(100) COLLATE "default",
"lock_number" varchar(20) COLLATE "default",
"company_id" varchar(32) COLLATE "default" NOT NULL,
"lock_ip" varchar(32) COLLATE "default",
"emp_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_mac
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_mac";
CREATE TABLE "public"."kq_mac" (
"mac_id" varchar(32) COLLATE "default" NOT NULL,
"mac" varchar(20) COLLATE "default",
"macname" varchar(40) COLLATE "default",
"company_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_operation_record
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_operation_record";
CREATE TABLE "public"."kq_operation_record" (
"operation_id" varchar(32) COLLATE "default" NOT NULL,
"operation_type" varchar(32) COLLATE "default",
"operation_date" varchar(32) COLLATE "default",
"emp_id" varchar(32) COLLATE "default" NOT NULL,
"company_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_statistics
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_statistics";
CREATE TABLE "public"."kq_statistics" (
"sts_id" varchar(32) COLLATE "default" NOT NULL,
"on_time" varchar COLLATE "default",
"off_time" varchar COLLATE "default",
"shicha" varchar(11) COLLATE "default",
"result" varchar(10) COLLATE "default" NOT NULL,
"on_flag" varchar(15) COLLATE "default",
"off_flag" varchar(15) COLLATE "default",
"emp_id" varchar(32) COLLATE "default",
"company_id" varchar(32) COLLATE "default",
"dept_id" varchar(32) COLLATE "default",
"create_time" varchar COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_timeset
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_timeset";
CREATE TABLE "public"."kq_timeset" (
"set_id" varchar(32) COLLATE "default" NOT NULL,
"am_time" varchar(100) COLLATE "default" NOT NULL,
"pm_time" varchar(100) COLLATE "default" NOT NULL,
"shiduan" varchar(20) COLLATE "default" NOT NULL,
"company_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_travel
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_travel";
CREATE TABLE "public"."kq_travel" (
"travel_id" varchar(32) COLLATE "default" NOT NULL,
"create_time" varchar(60) COLLATE "default" NOT NULL,
"travel_reason" varchar(100) COLLATE "default" NOT NULL,
"emp_id" varchar(32) COLLATE "default",
"company_id" varchar(32) COLLATE "default",
"dept_id" varchar(32) COLLATE "default",
"travel_starttime" varchar(50) COLLATE "default",
"travel_endtime" varchar(50) COLLATE "default",
"latitude" varchar(20) COLLATE "default",
"longitude" varchar(20) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_users
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_users";
CREATE TABLE "public"."kq_users" (
"company_id" varchar(32) COLLATE "default" NOT NULL,
"name" varchar(20) COLLATE "default" NOT NULL,
"username" varchar(30) COLLATE "default" NOT NULL,
"password" varchar(32) COLLATE "default",
"email" varchar(30) COLLATE "default" NOT NULL,
"company_name" varchar(50) COLLATE "default" NOT NULL,
"company_tel" varchar(16) COLLATE "default",
"company_logo" varchar(100) COLLATE "default",
"active_key" varchar(32) COLLATE "default",
"company_mac" varchar(100) COLLATE "default",
"active_code" varchar(32) COLLATE "default",
"latitude" varchar(20) COLLATE "default",
"longitude" varchar(20) COLLATE "default",
"mobilephone" varchar(16) COLLATE "default",
"checkmac" varchar(20) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_verify_log
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_verify_log";
CREATE TABLE "public"."kq_verify_log" (
"verify_log_id" varchar(32) COLLATE "default" NOT NULL,
"verify_id" varchar(32) COLLATE "default" NOT NULL,
"verify_result" int4 NOT NULL,
"verify_time" date NOT NULL,
"verify_number" varchar(10) COLLATE "default" NOT NULL,
"read_number" varchar(10) COLLATE "default" NOT NULL,
"normscore" float8,
"score" float8,
"verify_voice" oid NOT NULL,
"verify_type" int4,
"emp_id" varchar(32) COLLATE "default" NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_verifyrecord
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_verifyrecord";
CREATE TABLE "public"."kq_verifyrecord" (
"verify_id" varchar(32) COLLATE "default" NOT NULL,
"punch_time" varchar(50) COLLATE "default" NOT NULL,
"verify_result" int4 NOT NULL,
"verify_number" varchar(10) COLLATE "default" NOT NULL,
"read_number" varchar(10) COLLATE "default" NOT NULL,
"normscore" float8 NOT NULL,
"score" float8 NOT NULL,
"verify_voice" varchar(100) COLLATE "default" NOT NULL,
"verify_type" int4,
"verify_times" int4,
"emp_id" varchar(32) COLLATE "default",
"company_id" varchar(32) COLLATE "default",
"dept_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_vp
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_vp";
CREATE TABLE "public"."kq_vp" (
"vp_id" varchar(32) COLLATE "default" NOT NULL,
"model" varchar(100) COLLATE "default",
"voice" varchar(100) COLLATE "default",
"create_time" varchar(30) COLLATE "default" NOT NULL,
"company_id" varchar(32) COLLATE "default",
"dept_id" varchar(32) COLLATE "default",
"emp_id" varchar(32) COLLATE "default"
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Table structure for kq_vp_log
-- ----------------------------
DROP TABLE IF EXISTS "public"."kq_vp_log";
CREATE TABLE "public"."kq_vp_log" (
"vp_log_id" varchar(32) COLLATE "default" NOT NULL,
"vp_id" varchar(32) COLLATE "default" NOT NULL,
"create_time" date NOT NULL,
"mod_result" int4 NOT NULL,
"emp_id" varchar(32) COLLATE "default" NOT NULL
)
WITH (OIDS=FALSE)

;

-- ----------------------------
-- Alter Sequences Owned By
-- ----------------------------

-- ----------------------------
-- Primary Key structure for table kq_acs
-- ----------------------------
ALTER TABLE "public"."kq_acs" ADD PRIMARY KEY ("acs_id");

-- ----------------------------
-- Primary Key structure for table kq_admin
-- ----------------------------
ALTER TABLE "public"."kq_admin" ADD PRIMARY KEY ("admin_id");

-- ----------------------------
-- Primary Key structure for table kq_asuq
-- ----------------------------
ALTER TABLE "public"."kq_asuq" ADD PRIMARY KEY ("asuq_id");

-- ----------------------------
-- Primary Key structure for table kq_auth
-- ----------------------------
ALTER TABLE "public"."kq_auth" ADD PRIMARY KEY ("auth_id");

-- ----------------------------
-- Primary Key structure for table kq_dept
-- ----------------------------
ALTER TABLE "public"."kq_dept" ADD PRIMARY KEY ("dept_id");

-- ----------------------------
-- Primary Key structure for table kq_emp
-- ----------------------------
ALTER TABLE "public"."kq_emp" ADD PRIMARY KEY ("emp_id");

-- ----------------------------
-- Primary Key structure for table kq_employ
-- ----------------------------
ALTER TABLE "public"."kq_employ" ADD PRIMARY KEY ("epid");

-- ----------------------------
-- Primary Key structure for table kq_feedback
-- ----------------------------
ALTER TABLE "public"."kq_feedback" ADD PRIMARY KEY ("feedback_id");

-- ----------------------------
-- Primary Key structure for table kq_leave
-- ----------------------------
ALTER TABLE "public"."kq_leave" ADD PRIMARY KEY ("leave_id");

-- ----------------------------
-- Primary Key structure for table kq_loc
-- ----------------------------
ALTER TABLE "public"."kq_loc" ADD PRIMARY KEY ("loc_id");

-- ----------------------------
-- Primary Key structure for table kq_lock
-- ----------------------------
ALTER TABLE "public"."kq_lock" ADD PRIMARY KEY ("lock_id");

-- ----------------------------
-- Primary Key structure for table kq_mac
-- ----------------------------
ALTER TABLE "public"."kq_mac" ADD PRIMARY KEY ("mac_id");

-- ----------------------------
-- Primary Key structure for table kq_operation_record
-- ----------------------------
ALTER TABLE "public"."kq_operation_record" ADD PRIMARY KEY ("operation_id");

-- ----------------------------
-- Primary Key structure for table kq_statistics
-- ----------------------------
ALTER TABLE "public"."kq_statistics" ADD PRIMARY KEY ("sts_id");

-- ----------------------------
-- Primary Key structure for table kq_timeset
-- ----------------------------
ALTER TABLE "public"."kq_timeset" ADD PRIMARY KEY ("set_id");

-- ----------------------------
-- Primary Key structure for table kq_travel
-- ----------------------------
ALTER TABLE "public"."kq_travel" ADD PRIMARY KEY ("travel_id");

-- ----------------------------
-- Primary Key structure for table kq_users
-- ----------------------------
ALTER TABLE "public"."kq_users" ADD PRIMARY KEY ("company_id");

-- ----------------------------
-- Primary Key structure for table kq_verify_log
-- ----------------------------
ALTER TABLE "public"."kq_verify_log" ADD PRIMARY KEY ("verify_log_id");

-- ----------------------------
-- Primary Key structure for table kq_verifyrecord
-- ----------------------------
ALTER TABLE "public"."kq_verifyrecord" ADD PRIMARY KEY ("verify_id");

-- ----------------------------
-- Primary Key structure for table kq_vp
-- ----------------------------
ALTER TABLE "public"."kq_vp" ADD PRIMARY KEY ("vp_id");

-- ----------------------------
-- Primary Key structure for table kq_vp_log
-- ----------------------------
ALTER TABLE "public"."kq_vp_log" ADD PRIMARY KEY ("vp_log_id");

-- ----------------------------
-- Foreign Key structure for table "public"."kq_acs"
-- ----------------------------
ALTER TABLE "public"."kq_acs" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_acs" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_acs" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_asuq"
-- ----------------------------
ALTER TABLE "public"."kq_asuq" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_asuq" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_asuq" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_auth"
-- ----------------------------
ALTER TABLE "public"."kq_auth" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_auth" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_dept"
-- ----------------------------
ALTER TABLE "public"."kq_dept" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_emp"
-- ----------------------------
ALTER TABLE "public"."kq_emp" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_emp" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_leave"
-- ----------------------------
ALTER TABLE "public"."kq_leave" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_leave" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_leave" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_lock"
-- ----------------------------
ALTER TABLE "public"."kq_lock" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_lock" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_mac"
-- ----------------------------
ALTER TABLE "public"."kq_mac" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_operation_record"
-- ----------------------------
ALTER TABLE "public"."kq_operation_record" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_operation_record" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_statistics"
-- ----------------------------
ALTER TABLE "public"."kq_statistics" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_statistics" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_statistics" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_timeset"
-- ----------------------------
ALTER TABLE "public"."kq_timeset" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_travel"
-- ----------------------------
ALTER TABLE "public"."kq_travel" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_travel" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_travel" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_verifyrecord"
-- ----------------------------
ALTER TABLE "public"."kq_verifyrecord" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_verifyrecord" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_verifyrecord" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;

-- ----------------------------
-- Foreign Key structure for table "public"."kq_vp"
-- ----------------------------
ALTER TABLE "public"."kq_vp" ADD FOREIGN KEY ("emp_id") REFERENCES "public"."kq_emp" ("emp_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_vp" ADD FOREIGN KEY ("dept_id") REFERENCES "public"."kq_dept" ("dept_id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "public"."kq_vp" ADD FOREIGN KEY ("company_id") REFERENCES "public"."kq_users" ("company_id") ON DELETE CASCADE ON UPDATE CASCADE;

4.赋予权限(create_authority.sql)

GRANT all ON DATABASE "kq_acs" TO "kq_acs";
GRANT all ON SCHEMA "public" TO "kq_acs";
GRANT all ON all tables in SCHEMA "public" to "kq_acs";