SlideShare a Scribd company logo
1 of 9
Please accept this assignment if you're good in SQL!
Task:
CIS 353.
On answers which include SQL include your SQL and 5-10 lines
of the output.
1.
What is SQL?
2.
What are primary, unique and foreign key constraints?
What is referential integrity and how does it relate to these
constraints?
3.
Provide the DDL to make the PEOPLE_TEST table described
below.
Name
Null?
Type
-------------------------------
--------
----
SSN
NOT NULL
VARCHAR2(9)
LAST_NAME
NOT NULL
VARCHAR2(20)
FIRST_NAME
NOT NULL
VARCHAR2(15)
MIDDLE_NAME
VARCHAR2(15)
SEX
VARCHAR2(6)
CITY
VARCHAR2(30)
DOB
DATE
SALARY
NOT NULL
NUMBER(9,2)
Create the table in your schema.
4.
Provide the DML to insert this data into the PEOPLE_TEST
table.
303785523, BROWN, JOHN, JAY, MALE, GREENFIELD,10-
JAN-68,35000
313507927, SMITH, LINDA, SUE, FEMALE,
INDIANAPOLIS,24-MAR-85,50000
312667717, EDWARDS, NORMAN, HENRY, MALE,
GREENFIELD,20-APR-92,85000
420001690, GARCIA, STEVEN, LEE, MALE, INDIANAPOLIS,
17-AUG-65,55000
313456233, MEANS, LEONARD, ROBERT, MALE,
GREENFIELD,17-AUG-85,75000
490552223, OSBORNE, MARGARET,NULL , FEMALE,
INDIANAPOLIS,23-MAR-87,150000
5.
Select first_name, last_name command from PEOPLE_TEST in
sqlplus.
Use column command to format your output.
Cut and paste the first 10 lines of the result – including your
query and the col commands into your answer.
6.
What is undo?
Explain the terms rollback and commit.
Does DDL require a commit?
Does DML?
Why is committing early and often important?
7.
Create a table SORTA_RICH_PEOPLE_TEST with the same
structure as PEOPLE_TEST using CTAS.
Populate your new table only with people who make more than
$65000 in salary from PEOPLE_TEST.
Run the SQL and then display the SQL and a select * from
SORTA_RICH_PEOPLE_TEST in your answer.
Cut and paste the result – including your query into your
answer.
8.
You have stored several SQL commands in an ASCII/text file
on a floppy
(A:MY_COMMANDS.SQL).
You are logged into SQLPLUS.
Give the command to run this SQL script file.
How would you do this in designer?
9.
What is a view?
Give two reasons you would create a view.
10.
What is the system catalog or data dictionary?
Why do you care?
What are the user_*, all_* and dba_* views?
11.
You want to know the names of all the tables you own.
Give the SQL command.
Say one of the tables was
PEOPLE_TEST.
Now you want to see the table PEOPLE_TEST’s structure.
Give the SQL command.
Now you want to see all of the table PEOPLE_TEST’s data.
Give the SQL command.
12. You wish to create a user named George with a password of
thejungle whose default tablespace is users and whose
temporary tablespace is users. Give the SQL.
13.
What is a role?
Why do we make roles?
Give the SQL to grant the roles connect and resource to George.
14. What sort of data is stored in char and varchar2 columns?
How are the two columns different from each other?
15.
How is date data stored in the database?
What is the default date display format?
How can you change the default date display format?
16. What is a table? What is a tablespace?
17. Altering a table’s structure can be hard. Provide the DDL to
alter the PEOPLE_TEST table as follows if it can be done in a
single command or just explain why it can’t be done in a single
command.
a. Increase LAST_NAME to 30.
b.
Decrease MIDDLE_NAME to 12.
c.
Place a new column, TITLE, in the table positioned after
MIDDLE_NAME.
Make it VARCHAR2(15).
d.
Remove the SALARY column.
18.
Give the SQL to update PEOPLE_TEST
so that salary
is increased by 15% for everyone born before
Jan 1, 1980.
Make the change permanent.
19.
Give the SQL to update PEOPLE_TEST
so that females who make more than $80000 are deleted from
the table.
Don’t commit, in fact undo the change.
Give me the commands you used.
20. Give the SQL to select sex and the sum of salary from
PEOPLE_TEST for people from Indianapolis grouped by sex.
21.
Give the SQL to select sex and the sum of salary from
PEOPLE_TEST grouped by city and sex but only if the sum of
salary for a sex is greater than $150,000.
22.
Give the SQL to select all columns from PEOPLE_TEST if the
salary is greater than 55000 or the sex is male.
23.
Give the SQL to select all columns from PEOPLE_TEST if the
last name begins with
G
or
O.
24.
You want to know what 345 times 98 plus 97 is.
How could SQLPLUS tell you?
(Give SQL.)
25.
Give the SQL to select the last name,
salary, salary with a 15% raise and salary with a 25% raise from
PEOPLE_TEST.
Rename the last two output columns to raise_15 and raise_25.

More Related Content

Similar to Please accept this assignment if youre good in SQL!Task.docx

Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
pandey3045_bit
 

Similar to Please accept this assignment if youre good in SQL!Task.docx (20)

Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
Lab
LabLab
Lab
 
Sql basic best-course-in-mumbai
Sql basic best-course-in-mumbaiSql basic best-course-in-mumbai
Sql basic best-course-in-mumbai
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
Chapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdfChapter – 6 SQL Lab Tutorial.pdf
Chapter – 6 SQL Lab Tutorial.pdf
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
SQL Notes
SQL NotesSQL Notes
SQL Notes
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
 
Intro to SQL for Beginners
Intro to SQL for BeginnersIntro to SQL for Beginners
Intro to SQL for Beginners
 
Sql
SqlSql
Sql
 
Adbms 21 sql 99 schema definition constraints and queries
Adbms 21 sql 99 schema definition constraints and queriesAdbms 21 sql 99 schema definition constraints and queries
Adbms 21 sql 99 schema definition constraints and queries
 
SQL commands.docx
SQL commands.docxSQL commands.docx
SQL commands.docx
 
Sql (DBMS)
Sql (DBMS)Sql (DBMS)
Sql (DBMS)
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
 
Assignment#02
Assignment#02Assignment#02
Assignment#02
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Sql
SqlSql
Sql
 
Sql
SqlSql
Sql
 

More from needhamserena

class MyLinkedList2   copy of MyLinkedList in Fig. 15.4 {    priv.docx
class MyLinkedList2    copy of MyLinkedList in Fig. 15.4 {    priv.docxclass MyLinkedList2    copy of MyLinkedList in Fig. 15.4 {    priv.docx
class MyLinkedList2   copy of MyLinkedList in Fig. 15.4 {    priv.docx
needhamserena
 
Class Exercise – Module 6 (Workplace Law)Hardie is a printer w.docx
Class Exercise – Module 6 (Workplace Law)Hardie is a printer w.docxClass Exercise – Module 6 (Workplace Law)Hardie is a printer w.docx
Class Exercise – Module 6 (Workplace Law)Hardie is a printer w.docx
needhamserena
 
Class Exercise – Module 5 - CorporationsKelly is a director of I.docx
Class Exercise – Module 5 - CorporationsKelly is a director of I.docxClass Exercise – Module 5 - CorporationsKelly is a director of I.docx
Class Exercise – Module 5 - CorporationsKelly is a director of I.docx
needhamserena
 
CJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docx
CJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docxCJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docx
CJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docx
needhamserena
 
CJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docx
CJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docxCJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docx
CJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docx
needhamserena
 
CJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docx
CJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docxCJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docx
CJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docx
needhamserena
 

More from needhamserena (20)

Class type History since 1945Paper type Reaearch paper L.docx
Class type History since 1945Paper type Reaearch paper L.docxClass type History since 1945Paper type Reaearch paper L.docx
Class type History since 1945Paper type Reaearch paper L.docx
 
Class,One of the areas we will be discussing this week is .docx
Class,One of the areas we will be discussing this week is .docxClass,One of the areas we will be discussing this week is .docx
Class,One of the areas we will be discussing this week is .docx
 
Class type History since 1945Paper type Reaearch paper Length-.docx
Class type History since 1945Paper type Reaearch paper Length-.docxClass type History since 1945Paper type Reaearch paper Length-.docx
Class type History since 1945Paper type Reaearch paper Length-.docx
 
Class type History since 1945Paper type Reaearch paper Len.docx
Class type History since 1945Paper type Reaearch paper Len.docxClass type History since 1945Paper type Reaearch paper Len.docx
Class type History since 1945Paper type Reaearch paper Len.docx
 
Class Transportation EconomicsQuestionDescribe the major com.docx
Class Transportation EconomicsQuestionDescribe the major com.docxClass Transportation EconomicsQuestionDescribe the major com.docx
Class Transportation EconomicsQuestionDescribe the major com.docx
 
Class type History since 1945Paper type Reaearch paper Lengt.docx
Class type History since 1945Paper type Reaearch paper Lengt.docxClass type History since 1945Paper type Reaearch paper Lengt.docx
Class type History since 1945Paper type Reaearch paper Lengt.docx
 
Class Project build a data warehouse and to do a presentation of t.docx
Class Project build a data warehouse and to do a presentation of t.docxClass Project build a data warehouse and to do a presentation of t.docx
Class Project build a data warehouse and to do a presentation of t.docx
 
class MyLinkedList2   copy of MyLinkedList in Fig. 15.4 {    priv.docx
class MyLinkedList2    copy of MyLinkedList in Fig. 15.4 {    priv.docxclass MyLinkedList2    copy of MyLinkedList in Fig. 15.4 {    priv.docx
class MyLinkedList2   copy of MyLinkedList in Fig. 15.4 {    priv.docx
 
Class Exercise – Module 6 (Workplace Law)Hardie is a printer w.docx
Class Exercise – Module 6 (Workplace Law)Hardie is a printer w.docxClass Exercise – Module 6 (Workplace Law)Hardie is a printer w.docx
Class Exercise – Module 6 (Workplace Law)Hardie is a printer w.docx
 
Class Exercise – Module 8 – Real PropertyHarvey sold his house.docx
Class Exercise – Module 8 – Real PropertyHarvey sold his house.docxClass Exercise – Module 8 – Real PropertyHarvey sold his house.docx
Class Exercise – Module 8 – Real PropertyHarvey sold his house.docx
 
Class is Social Responsibility Write a 2-page analysis connectin.docx
Class is Social Responsibility Write a 2-page analysis connectin.docxClass is Social Responsibility Write a 2-page analysis connectin.docx
Class is Social Responsibility Write a 2-page analysis connectin.docx
 
Class Exercise – Module 5 - CorporationsKelly is a director of I.docx
Class Exercise – Module 5 - CorporationsKelly is a director of I.docxClass Exercise – Module 5 - CorporationsKelly is a director of I.docx
Class Exercise – Module 5 - CorporationsKelly is a director of I.docx
 
Class EDU 160 Child Developement and HealthPEAssignment Colle.docx
Class EDU 160 Child Developement and HealthPEAssignment Colle.docxClass EDU 160 Child Developement and HealthPEAssignment Colle.docx
Class EDU 160 Child Developement and HealthPEAssignment Colle.docx
 
Class Ethical Decision Making Through FilmAssignment 1500 WORD.docx
Class Ethical Decision Making Through FilmAssignment 1500 WORD.docxClass Ethical Decision Making Through FilmAssignment 1500 WORD.docx
Class Ethical Decision Making Through FilmAssignment 1500 WORD.docx
 
Clarify the differences between referential and expressive language..docx
Clarify the differences between referential and expressive language..docxClarify the differences between referential and expressive language..docx
Clarify the differences between referential and expressive language..docx
 
Class INF220Each discussion must be at least 200 words.docx
Class  INF220Each discussion must be at least 200 words.docxClass  INF220Each discussion must be at least 200 words.docx
Class INF220Each discussion must be at least 200 words.docx
 
CJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docx
CJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docxCJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docx
CJUS300Sarah Harris, your supervisor at the pretrial diversion pro.docx
 
CJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docx
CJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docxCJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docx
CJUS300Cindy Hart is 23 years of age. She was born on 61186, the.docx
 
CJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docx
CJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docxCJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docx
CJHS311-1501B-01 Study of Alcohol Use and AbuseTask NamePhase 2.docx
 
CJHS315-1404B-01 Child AbuseTask NamePhase 1 Individual Project.docx
CJHS315-1404B-01 Child AbuseTask NamePhase 1 Individual Project.docxCJHS315-1404B-01 Child AbuseTask NamePhase 1 Individual Project.docx
CJHS315-1404B-01 Child AbuseTask NamePhase 1 Individual Project.docx
 

Recently uploaded

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 

Please accept this assignment if youre good in SQL!Task.docx

  • 1. Please accept this assignment if you're good in SQL! Task: CIS 353. On answers which include SQL include your SQL and 5-10 lines of the output. 1. What is SQL? 2. What are primary, unique and foreign key constraints? What is referential integrity and how does it relate to these constraints? 3. Provide the DDL to make the PEOPLE_TEST table described below. Name Null? Type -------------------------------
  • 2. -------- ---- SSN NOT NULL VARCHAR2(9) LAST_NAME NOT NULL VARCHAR2(20) FIRST_NAME NOT NULL VARCHAR2(15) MIDDLE_NAME VARCHAR2(15) SEX VARCHAR2(6) CITY VARCHAR2(30) DOB
  • 3. DATE SALARY NOT NULL NUMBER(9,2) Create the table in your schema. 4. Provide the DML to insert this data into the PEOPLE_TEST table. 303785523, BROWN, JOHN, JAY, MALE, GREENFIELD,10- JAN-68,35000 313507927, SMITH, LINDA, SUE, FEMALE, INDIANAPOLIS,24-MAR-85,50000 312667717, EDWARDS, NORMAN, HENRY, MALE, GREENFIELD,20-APR-92,85000 420001690, GARCIA, STEVEN, LEE, MALE, INDIANAPOLIS, 17-AUG-65,55000 313456233, MEANS, LEONARD, ROBERT, MALE, GREENFIELD,17-AUG-85,75000 490552223, OSBORNE, MARGARET,NULL , FEMALE, INDIANAPOLIS,23-MAR-87,150000 5.
  • 4. Select first_name, last_name command from PEOPLE_TEST in sqlplus. Use column command to format your output. Cut and paste the first 10 lines of the result – including your query and the col commands into your answer. 6. What is undo? Explain the terms rollback and commit. Does DDL require a commit? Does DML? Why is committing early and often important? 7. Create a table SORTA_RICH_PEOPLE_TEST with the same structure as PEOPLE_TEST using CTAS. Populate your new table only with people who make more than $65000 in salary from PEOPLE_TEST. Run the SQL and then display the SQL and a select * from SORTA_RICH_PEOPLE_TEST in your answer. Cut and paste the result – including your query into your answer. 8.
  • 5. You have stored several SQL commands in an ASCII/text file on a floppy (A:MY_COMMANDS.SQL). You are logged into SQLPLUS. Give the command to run this SQL script file. How would you do this in designer? 9. What is a view? Give two reasons you would create a view. 10. What is the system catalog or data dictionary? Why do you care? What are the user_*, all_* and dba_* views? 11. You want to know the names of all the tables you own. Give the SQL command. Say one of the tables was PEOPLE_TEST.
  • 6. Now you want to see the table PEOPLE_TEST’s structure. Give the SQL command. Now you want to see all of the table PEOPLE_TEST’s data. Give the SQL command. 12. You wish to create a user named George with a password of thejungle whose default tablespace is users and whose temporary tablespace is users. Give the SQL. 13. What is a role? Why do we make roles? Give the SQL to grant the roles connect and resource to George. 14. What sort of data is stored in char and varchar2 columns? How are the two columns different from each other? 15. How is date data stored in the database? What is the default date display format? How can you change the default date display format? 16. What is a table? What is a tablespace? 17. Altering a table’s structure can be hard. Provide the DDL to alter the PEOPLE_TEST table as follows if it can be done in a
  • 7. single command or just explain why it can’t be done in a single command. a. Increase LAST_NAME to 30. b. Decrease MIDDLE_NAME to 12. c. Place a new column, TITLE, in the table positioned after MIDDLE_NAME. Make it VARCHAR2(15). d. Remove the SALARY column. 18. Give the SQL to update PEOPLE_TEST so that salary is increased by 15% for everyone born before Jan 1, 1980. Make the change permanent. 19. Give the SQL to update PEOPLE_TEST
  • 8. so that females who make more than $80000 are deleted from the table. Don’t commit, in fact undo the change. Give me the commands you used. 20. Give the SQL to select sex and the sum of salary from PEOPLE_TEST for people from Indianapolis grouped by sex. 21. Give the SQL to select sex and the sum of salary from PEOPLE_TEST grouped by city and sex but only if the sum of salary for a sex is greater than $150,000. 22. Give the SQL to select all columns from PEOPLE_TEST if the salary is greater than 55000 or the sex is male. 23. Give the SQL to select all columns from PEOPLE_TEST if the last name begins with G or O. 24. You want to know what 345 times 98 plus 97 is.
  • 9. How could SQLPLUS tell you? (Give SQL.) 25. Give the SQL to select the last name, salary, salary with a 15% raise and salary with a 25% raise from PEOPLE_TEST. Rename the last two output columns to raise_15 and raise_25.