0% found this document useful (0 votes)
85 views4 pages

OBJECTIVE: Creating and Altering Tables

This lab document outlines tasks for creating and altering database tables. The tasks include: 1) Creating a jobs table with columns including max_salary that cannot exceed 25000. 2) Creating a jobs table with default values for some columns. 3) Creating an employees table with constraints to prevent duplicate values and require valid foreign keys. 4) Altering the salary of an employee with ID 105 if their existing salary is less than 5000.

Uploaded by

Farjad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views4 pages

OBJECTIVE: Creating and Altering Tables

This lab document outlines tasks for creating and altering database tables. The tasks include: 1) Creating a jobs table with columns including max_salary that cannot exceed 25000. 2) Creating a jobs table with default values for some columns. 3) Creating an employees table with constraints to prevent duplicate values and require valid foreign keys. 4) Altering the salary of an employee with ID 105 if their existing salary is less than 5000.

Uploaded by

Farjad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Database Systems (SWE-209L) SSUET/QR/114

Lab # 3: Creating and Altering Tables

LAB # 3
CREATING AND ALTERING TABLES

OBJECTIVE: Creating and altering tables.

LAB TASKS:
1. 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.
QUERY:

OUTPUT:
If I will enter max_sal greater than 25000 it will give error and do not run the query
because we have set the condition in the query that check (max_sal <= 25000).

This study source SYED


was downloaded
TAYYAB by 100000820744938 from [Link] on 04-04-2022 [Link] GMT -05:00
RAZA ZAIDI (2020-SE-272) 1

[Link]
Introduction to Database Systems (SWE-209L) SSUET/QR/114

Lab # 3: Creating and Altering Tables

2. Write a SQL statement to create a table named jobs including columns job_id,
job_title, min_salary and max_salary, and make sure that, the default value for
job_title is blank and min_salary is 10000 and max_salary is NULL will be entered
automatically at the time of insertion if no value assigned for the specified columns.
QUERY:

OUTPUT:

3. Write a SQL statement to create a table employees including columns employee_id,


first_name, last_name, email, phone_number hire_date, job_id, salary, commission,
manager_id and department_id and make sure that, the employee_id column does not contain
any duplicate value at the time of insertion and the foreign key columns combined by
department_id and manager_id columns contain only those unique combination values, which
combinations are exists in the departments table. Assume the structure of departments table
below.

This study source SYED


was downloaded
TAYYAB by 100000820744938 from [Link] on 04-04-2022 [Link] GMT -05:00
RAZA ZAIDI (2020-SE-272) 2

[Link]
Introduction to Database Systems (SWE-209L) SSUET/QR/114

Lab # 3: Creating and Altering Tables

QUERY:

OUTPUT:

This study source SYED


was downloaded
TAYYAB by 100000820744938 from [Link] on 04-04-2022 [Link] GMT -05:00
RAZA ZAIDI (2020-SE-272) 3

[Link]
Introduction to Database Systems (SWE-209L) SSUET/QR/114

Lab # 3: Creating and Altering Tables

4. Write a SQL statement to change salary of employee to 8000 whose ID is 105, if the existing
salary is less than 5000.
QUERY:

OUTPUT:

This study source SYED


was downloaded
TAYYAB by 100000820744938 from [Link] on 04-04-2022 [Link] GMT -05:00
RAZA ZAIDI (2020-SE-272) 4

[Link]
Powered by TCPDF ([Link])

You might also like