Write a postgre SQL statement to create a table employees including columns employee_id, first_name, last_name, job_id, salary and make sure that
- Postgre SQL
- 2021-09-29
- mhanasmh00489829403
الأجوبة
CREATE TABLE employees (
EMPLOYEE_ID decimal(6,0) NOT NULL PRIMARY KEY,
FIRST_NAME varchar(20) DEFAULT NULL,
LAST_NAME varchar(25) NOT NULL,
JOB_ID INTEGER,
SALARY decimal(8,2) DEFAULT NULL,
FOREIGN KEY(JOB_ID)
REFERENCES jobs(JOB_ID)
ON DELETE SET NULL
ON UPDATE SET NULL
);
Output:
postgres=# CREATE TABLE employees ( postgres(# EMPLOYEE_ID decimal(6,0) NOT NULL PRIMARY KEY, postgres(# FIRST_NAME varchar(20) DEFAULT NULL, postgres(# LAST_NAME varchar(25) NOT NULL, postgres(# JOB_ID INTEGER, SALARY decimal(8,2) DEFAULT NULL, postgres(# FOREIGN KEY(JOB_ID) postgres(# REFERENCES jobs(JOB_ID) postgres(# ON DELETE SET NULL ON UPDATE SET NULL postgres(# ); CREATE TABLE
Here is the command to see the structure of the created table :
postgres=# \d employees
Table "public.employees"
Column | Type | Modifiers
-------------+-----------------------+---------------------------------
employee_id | numeric(6,0) | not null
first_name | character varying(20) | default NULL::character varying
last_name | character varying(25) | not null
job_id | integer |
salary | numeric(8,2) | default NULL::numeric
Indexes:
"employees_pkey" PRIMARY KEY, btree (employee_id)
Foreign-key constraints:
"employees_job_id_fkey" FOREIGN KEY (job_id) REFERENCES jobs(job_id) ON UPDATE SET NULL ON DELETE SET NULL
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة