CREATE TABLE AS SELECT 语句
CREATE TABLE emp2
AS
SELECT * FROM employee;
CREATE TABLE emp2
AS
SELECT * FROM employee
WITH NO DATA;
CREATE TABLE emp2
AS
SELECT * FROM employee
WHERE FALSE;
CREATE TABLE LIKE 语句
CREATE TABLE emp3
(LIKE employee);
CREATE TABLE AS TABLE 语句
CREATE TABLE emp4
AS
TABLE employee;
CREATE TABLE emp4
AS
TABLE employee
WITH NO DATA;
SELECT INTO 语句
SELECT * INTO emp5 FROM employee;
CREATE TABLE INHERITS 语句
CREATE TABLE emp5 (
notes text NOT NULL
)
INHERITS ( employee );
\d emp5
Table "public.emp5"
Column | Type | Collation | Nullable | Default
-----------+------------------------+-----------+----------+---------
emp_id | integer | | not null |
emp_name | character varying(50) | | not null |
sex | character varying(10) | | not null |
dept_id | integer | | not null |
manager | integer | | |
hire_date | date | | not null |
job_id | integer | | not null |
salary | numeric(8,2) | | not null |
bonus | numeric(8,2) | | |
email | character varying(100) | | not null |
notes | text | | not null |
Check constraints:
"ck_emp_salary" CHECK (salary > 0::numeric)
"ck_emp_sex" CHECK (sex::text = ANY (ARRAY['男'::character varying, '女'::character varying]::text[]))
Inherits: employee
文章转载自SQL编程思想,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




