0% found this document useful (0 votes)
34 views3 pages

1 - Insert Rows Into The Table

The document provides the structure of a countries table and instructions to write SQL statements to: 1) Insert records into countries with specified column values 2) Insert a record with values for country_id and country_name 3) Create a duplicate table named country_new with the same structure and data 4) Insert NULL values for the region_id column 5) Insert 3 rows with a single statement 6) Insert rows from country_new into countries

Uploaded by

Hiền Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

1 - Insert Rows Into The Table

The document provides the structure of a countries table and instructions to write SQL statements to: 1) Insert records into countries with specified column values 2) Insert a record with values for country_id and country_name 3) Create a duplicate table named country_new with the same structure and data 4) Insert NULL values for the region_id column 5) Insert 3 rows with a single statement 6) Insert rows from country_new into countries

Uploaded by

Hiền Trần
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Write a SQL statement to insert a record with your own value


into the table countries against each columns.

Here in the following is the structure of the table countries.


+--------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+-------+
| COUNTRY_ID | varchar(2) | YES | | NULL | |
| COUNTRY_NAME | varchar(40) | YES | | NULL | |
| REGION_ID | decimal(10,0) | YES | | NULL | |
+--------------+---------------+------+-----+---------+-------+
2. Write a SQL statement to insert one row into the table
countries against the column country_id and country_name.

Here in the following is the structure of the table countries.


+--------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+-------+
| COUNTRY_ID | varchar(2) | YES | | NULL | |
| COUNTRY_NAME | varchar(40) | YES | | NULL | |
| REGION_ID | decimal(10,0) | YES | | NULL | |
+--------------+---------------+------+-----+---------+-------+
3. Write a SQL statement to create duplicate of countries table
named country_new with all structure and data.

Here in the following is the structure of the table countries.


+--------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+---------------+------+-----+---------+-------+
| COUNTRY_ID | varchar(2) | YES | | NULL | |
| COUNTRY_NAME | varchar(40) | YES | | NULL | |
| REGION_ID | decimal(10,0) | YES | | NULL | |
+--------------+---------------+------+-----+---------+-------+
4. Write a SQL statement to insert NULL values against region_id
column for a row of countries table.

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


statement.
6. Write a SQL statement insert rows from country_new table to
countries table.

Here is the rows for country_new table. Assume that, the


countries table is empty.
+------------+--------------+-----------+
| COUNTRY_ID | COUNTRY_NAME | REGION_ID |
+------------+--------------+-----------+
| C0001 | India | 1001 |
| C0002 | USA | 1007 |
| C0003 | UK | 1003 |
+------------+--------------+-----------+
7. Write a SQL statement to insert one row in jobs table to
ensure that no duplicate value will be entered in the job_id
column.

10. Write a SQL statement to insert rows into the table countries
in which the value of country_id column will be unique and auto
incremented.

11. Write a SQL statement to insert records into the table


countries to ensure that the country_id column will not contain
any duplicate data and this will be automatically incremented
and the column country_name will be filled up by 'N/A' if no value
assigned for that column.

12. Write a SQL statement to insert rows in the job_history table


in which one column job_id is containing those values which are
exists in job_id column of jobs table.

13. Write a SQL statement to insert rows into the table


employees in which a set of columns department_id and
manager_id contains a unique value and that combined values
must have exists into the table departments.

14. Write a SQL statement to insert rows into the table


employees in which a set of columns department_id and job_id
contains the values which must have exists into the table
departments and jobs.

You might also like