PostgreSQL 建库建表脚本
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";
PostgreSQL 建库建表脚本的更多相关文章
- MySQL建库建表
一直使用SQL SERVER 数据库:最近项目使用MY SQL感觉还是有一点不适应.不过熟悉之后就会好很多. MY SQL 安装之后会有一个管理工具MySQL Workbench 感觉不太好用,数据库 ...
- 【ITOO 2】.NET 动态建库建表:使用SQL字符串拼接方式
导读:在最近接手的项目(高效云平台)中,有一个需求是要当企业用户注册时,给其动态的新建一个库和表.刚开始接手的时候,是一点头绪都没有,然后查了一些资料,也问了问上一版本的师哥师姐,终于有了点头绪.目前 ...
- 【ITOO 3】.NET 动态建库建表:实用EF框架提供的codeFirst实现动态建库
导读:在上篇博客中,介绍了使用SQL字符拼接的方式,实现动态建库建表的方法.这样做虽然也能够实现效果,但是,太麻烦,而且,如果改动表结构,字段的话,会对代码修改很多.但是EF给我们提供了一种代码先行的 ...
- SQL Server建库-建表-建约束
----------------------------------------SQL Server建库-建表-建约束创建School数据库------------------------------ ...
- 使用T-sql建库建表建约束
为什么要使用sql语句建库建表? 现在假设这样一个场景,公司的项目经过测试没问题后需要在客户的实际环境中进行演示,那就需要对数据进行移植,现在问题来了:客户的数据库版本和公司开发阶段使用的数据库不兼容 ...
- mysql那些事(4)建库建表编码的选择
mysql建数据库或者建表的时候会遇到选择编码的问题,以前我们都是习惯性的选择utf8,但是在mysql在5.5.3版本后加了utf8mb4的编码,utf8mb4可以存4个字节Unicode,mb4就 ...
- C# 利用*.SQL文件自动建库建表等的类
/// <summary> /// 自动建库建表 /// </summary> public class OperationSqlFile { SqlConnection sq ...
- MySql 建库建表脚本
1.建库 CREATE DATABASE test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 2.建表脚本 CREATE TABLE `c ...
- Mysql建库建用户建表等常用命令
格式: mysql -h主机地址 -u用户名 -p用户密码 1.连接到本机上的MYSQL.首先打开DOS窗口,然后进入目录mysql\bin,再键入命令mysql -u root -p,回车后提示你输 ...
- oracle 11g 建库 建表 增 删 改 查 约束
一.建库 1.(点击左上角带绿色+号的按钮) 2.(进入这个界面,passowrd为密码.填写完后点击下面一排的Test按钮进行测试,无异常就点击Connect) 二.建表 1-1. create t ...
随机推荐
- CentOS 7 安装oracle 11.2.0.4 Error in invoking target 'agent nmhs' of makefile
%86时出现报错 Error in invoking target 'agent nmhs' of makefile 解决方案在makefile中添加链接libnnz11库的参数修改$ORACLE ...
- (暴力碾标算)NOIP模拟赛 宗教仪式
题意: 一个模式串,一个文本串,现定义最大失配值为k 求文本中最大失配值<=k的长度为len(模式串)的字串个数 失配值=当前字串中与模式串不同的字符个数 思路: 暴力,加一个跳出剪枝,居然过了 ...
- ABAP术语-Function Module
Function Module 原文:http://www.cnblogs.com/qiangsheng/archive/2008/02/18/1071827.html General-purpose ...
- linux命令之磁盘和文件系统操作
1. fdisk:磁盘分区命令 语法:fdisk [选项][参数] 命令说明:fdisk是linux系统里常用的一种磁盘管理工具,可以创建和管理系统分区 常用命令选项: -l:列出指定的并退出,没 ...
- 前端pc版的简单适配
我们都知道对于前端pc版本的适配是一个难题,大部分都是做的媒体查询.但是有时间公司不要媒体查询 就是需要不管多大的屏幕都是满屏显示.我就在考虑为啥不用rem给pc端做个适配. 我是基于设计图是1920 ...
- js获取播放器播放时间和停止播放
html代码 <video id="myVideo" class="video-active" width="100%" height ...
- 第1章 MATLAB概述
MATLAB系统由~开发环境.~语言.~数学函数库.~图形处理系统.~应用程序接口(API)5大部分组成. 界面 命令行中的语句格式 命令行的语句格式:>>变量=表达式(没有>> ...
- Leecode刷题之旅-C语言/python-69x的平方根
/* * @lc app=leetcode.cn id=69 lang=c * * [69] x 的平方根 * * https://leetcode-cn.com/problems/sqrtx/des ...
- Test类实验
package PC_TEST; class CPU{ int speed; CPU(){ speed=0; } CPU(int k){ speed=k; } void setSpeed(int k) ...
- http报文和浏览器缓存机制
目录 1. 请求报文 1.1请求行 1.2 请求头 一些常用的请求头信息 2. 响应报文 2.1 状态行 1> 响应状态码 2> 常见的响应状态码 2.2 响应头 3. 浏览器缓存 3.1 ...