Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

SQL_Code_Questions.pdf

Rating
-
Sold
-
Pages
38
Uploaded on
14-07-2024
Written in
2023/2024

SQL_Code_Q

Institution
Course

Content preview

SQL Code Questions
MySQL Create Table Questions
1. Write a SQL statement to create a simple table countries including columns
country_id,country_name and region_id.


CREATE TABLE countries(
COUNTRY_ID varchar(2),
COUNTRY_NAME varchar(40),
REGION_ID decimal(10,0)
);
DESC countries;




Here is the structure of the table:




2. Write a SQL statement to create a simple table countries including columns
country_id,country_name and region_id which is already exists.


CREATE TABLE IF NOT EXISTS countries (
COUNTRY_ID varchar(2),
COUNTRY_NAME varchar(40),
REGION_ID decimal(10,0)
);




Here is the structure of the table:




SQL Code Questions 1

, 3. Write a SQL statement to create the structure of a table dup_countries
similar to countries.


CREATE TABLE IF NOT EXISTS dup_countries
LIKE countries;




Here is the structure of the table:




4. Write a SQL statement to create a duplicate copy of countries table
including structure and data by name dup_countries.


CREATE TABLE IF NOT EXISTS dup_countries
AS SELECT * FROM countries;




Here is the structure of the table:




SQL Code Questions 2

, 5. Write a SQL statement to create a table countries set a constraint NULL.


CREATE TABLE IF NOT EXISTS countries (
COUNTRY_ID varchar(2) NOT NULL,
COUNTRY_NAME varchar(40) NOT NULL,
REGION_ID decimal(10,0) NOT NULL
);




Here is the structure of the table:




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


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)
);




Here is the structure of the table:




SQL Code Questions 3

, 7. Write a SQL statement to create a table named countries including columns
country_id, country_name and region_id and make sure that no countries
except Italy, India and China will be entered in the table.


CREATE TABLE IF NOT EXISTS countries (
COUNTRY_ID varchar(2),
COUNTRY_NAME varchar(40)
CHECK(COUNTRY_NAME IN('Italy','India','China')) ,
REGION_ID decimal(10,0)
);




8. Write a SQL statement to create a table named job_histry including columns
employee_id, start_date, end_date, job_id and department_id and make sure
that the value against column end_date will be entered at the time of insertion
to the format like '--/--/----'.


CREATE TABLE IF NOT EXISTS job_history (
EMPLOYEE_ID decimal(6,0) NOT NULL,
START_DATE date NOT NULL,
END_DATE date NOT NULL
CHECK (END_DATE LIKE '--/--/----'),
JOB_ID varchar(10) NOT NULL,
DEPARTMENT_ID decimal(4,0) NOT NULL
);




SQL Code Questions 4

Written for

Institution
Course

Document information

Uploaded on
July 14, 2024
Number of pages
38
Written in
2023/2024
Type
OTHER
Person
Unknown

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
rajeshrawat

Also available in package deal

Get to know the seller

Seller avatar
rajeshrawat Rajesh rawat
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions