Q:

Write a postgre SQL statement to create a table named jobs, including job_id, job_title, min_salary, max_salary and check whether the max_salary amount exceeding the upper limit 25000

0

 Write a  postgre SQL statement to create a table named jobs, including job_id, job_title, min_salary, max_salary and check whether the max_salary amount exceeding the upper limit 25000

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

CREATE TABLE IF NOT EXISTS jobs ( 
JOB_ID varchar(10) NOT NULL , 
JOB_TITLE varchar(35) NOT NULL, 
MIN_SALARY decimal(6,0), 
MAX_SALARY decimal(6,0) 
CHECK(MAX_SALARY<=25000)
);

Output:

postgres=# CREATE TABLE IF NOT EXISTS jobs (
postgres(# JOB_ID varchar(10) NOT NULL ,
postgres(# JOB_TITLE varchar(35) NOT NULL,
postgres(# MIN_SALARY decimal(6,0),
postgres(# MAX_SALARY decimal(6,0)
postgres(# CHECK(MAX_SALARY<=25000)
postgres(# );
CREATE TABLE

Here is command to see the structure of the created table :

postgres=# \d jobs;
             Table "public.jobs"
   Column   |         Type          | Modifiers
------------+-----------------------+-----------
 job_id     | character varying(10) | not null
 job_title  | character varying(35) | not null
 min_salary | numeric(6,0)          |
 max_salary | numeric(6,0)          |
Check constraints:
    "jobs_max_salary_check" CHECK (max_salary <= 25000::numeric)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now