You are on page 1of 1

1.

Write a SQL statement to insert a record with your own value into the table
countries against each column.
insert into countries2(country_id,country_name,region_id)values
('01','India','101');

2. Write a SQL statement to insert one row into the table countries against the
column country_id and country_name.
insert into countries2(country_id,country_name)values ('02','Italy');

3. Write a SQL statement to insert NULL values into region_id column for a row of
countries table.
insert into countries3(region_id)values (null);

4. Write a SQL statement to insert 3 rows by a single insert statement.


insert into countries3(country_id,country_name,region_id)values
('01','India','101'),('02','America','102'),('03','Canada','103');

5. Write a SQL statement insert rows from the country_new table to countries table.
insert into countries3 select * from country_new;

6. Write a SQL statement to insert one row in the jobs table to ensure that no
duplicate values will be entered into the job_id column.
create table jobs( job_id numeric primary key unique,job_title
varchar(50) ,min_salary numeric,max_salary numeric);
//error
insert into
jobs(job_id,job_title,min_salary,max_salary)values('101','Consultant','50000','3000
'),('101','Finance','3000','10000');
//correct
insert into
jobs(job_id,job_title,min_salary,max_salary)values('101','Consultant','50000','3000
'),('102','Finance','3000','10000');

7. Write a SQL statement to insert a record into the table countries to ensure
that, at country_id and the region_id combination will be entered once in the
table.

8. Write a SQL statement to insert rows into the job_history table in which one
column job_id is containing those values which exist in job_id column of jobs
table.
create table job_his11(employee_id numeric primary key,
start_date date,
end_date date,
job_id numeric,
department_id numeric,
foreign key(job_id)references jobs1(job_id));
//error
insert into
job_his11(employee_id,start_date,end_date,job_id,department_id)values('201','04-01-
2022','10-02-2022','103','3000');

//correct
insert into
job_his11(employee_id,start_date,end_date,job_id,department_id)values('201','04-01-
2022','10-02-2022','102','3000');

You might also like