This page provides answers for the SQL Problem sets.
SQL Exercise Set #2 | ||
1. Create a duplicate EMP table. Name it EMPTEST. | SELECT Emp.* INTO EmpTest
FROM Emp; |
|
2. Add a new column named SEX to the EMPTEST table with a datatype of character and a length of 1. | alter table emptest
add column sex char(1) |
|
3. The users have changed their minds. Instead of storing SEX as F or M, they want to use MALE or FEMALE. Increase the size of the SEX field accordingly. | alter table emptest
alter column sex char(7) |
|
4. Create a query named EMP_NO_MONEY with all columns from the EMP table except the SAL and COMM columns. |
|
|
5. Go to the menu Tools | Options and select the View tab. Check the "System Objects" box. Select all columns from the system table MSysQueries.. |
|
|
6. Using your query EMP_NO_MONEY, create a new query to display all employee names and hire dates. |
|
|
7. What happens when you look for salary in EMP_NO_MONEY? | Since the salary column was not selected in the EMP_NO_MONEY query definition, it is not available for subsequent queries created with EMP_NO_MONEY as their source. | |
8. Create a query named EMP_DEPTNO_TEN that includes only the employee name, department number, and employee number from the EMP table. Construct the query so that only employees in department 10 are visible. |
|
|
9. Enter any query using EMP_DEPTNO_TEN. |
|
|
10. Delete the query. | drop table EMP_DEPTNO_TEN_NEW |
SQL Problem Sets |