Question

Lesson 10Create the DEPARTMENT tables based on the following: Column Name   ID      Name Data Type     Number...

Lesson 10Create the DEPARTMENT tables based on the following:

Column Name   ID      Name

Data Type     Number Varchar2

Length        7      25

Populate the DEPARTMENT table with data from the DEPT table. Include only columns that you need.

Create the EMPLOYEE table based on the following table chart:

Column Name    ID      LAST_NAME     FIRST_NAME     DEPT_ID

Data Type      Number Varchar2      Varchar2       Number

Length         7       25            25             7

Modify the EMPLOYEE table to allow for longer employee last names. Confirm your modification.

Confirm that both the DEPARTMENT and EMPLOYEE tables are stored in the data dictionary. (Hint: USER_TABLES)

Create the EMPLOYEE2 table based on the structure of the EMP table. Include only the EMPO, ENAME, DEPTNO columns. Name the columns in your new table ID, LAST_NAME, and DEPT_ID, respectively.

Drop the EMPLOYEE table.

Rename the EMPLOYEE2 table to EMPLOYEE.

Add a comment to the DEPARTMENT and EMPLOYEE table definitions describing the tables. Confirm your additions in the data dictionary.

Drop the LAST_NAME column from the EMPLOYEE table. Confirm your modification by checking the description of the table.

Create the EMPLOYEE2 table based on the structure of the EMP table. Include only the EMPNO, ENAME, DEPT_ID columns. Name the columns in your new table ID, LAST_NAME, and DEPT_ID, respectively. Mark the DEPT_ID column in the EMPLOYEE2 table as UNUSED. Confirm your modification by checking the description of the table.

Drop all the UNUSED columns from the EMPLOYEE2 table. Confirm your modifications by checking the description of the table.

Lesson 11

Add a table-level PRIMARY KEY constraint to the EMPLOYEE table using the ID column. The constraint should be named at creation.

Create a PRIMARY KEY constraint on the DEPARTMENT table using the ID column. The constraint should be named at creation.

Add a foreign key reference on the EMPLOYEE table that will ensure that the employee is not assigned to a nonexistent department.

Confirm that the constraints were added by querying USER_CONSTRAINTS. Note the types and names of the constraints and include them in your statement comments.

Display the object names and types from the USER_OBJECTS data dictionary view for EMPLOYEE and DEPARTMENT tables. You will want to format the columns for readability. Provide comments that include the new tables and indexes created.

Modify the EMPLOYEE table by adding a SALARY column of NUMBER data type, precision 7.

HERE IS THE SCRIPT TO BUILD THE ORIGINAL TABLE:

SET ECHO OFF

SET FEEDBACK OFF

PROMPT Creating the MY_EMPLOYEE table. Please wait...

CREATE TABLE my_employee

(id NUMBER(4)

CONSTRAINT my_employee_id_nn NOT NULL,

last_name VARCHAR2(25),

first_name VARCHAR2(25),

userid VARCHAR2(8),

salary NUMBER(9,2))

/

PROMPT Table MY_EMPLOYEE has been created.

SET FEEDBACK ON

SET ECHO ON

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program :

1 *Column Name ID Name Data Type Number Varchar2 Length 7 25*/ 2 CREATE TABLE DEPARTMENT ID NUMBER (7) NOT NULL, Name VARCHAR2 (25)) 4 /*Populate the DEPARTMENT table with data from the DEPT table. Include only columns that you need.*/ 2 5 SELECT DEPTNO, DNAME INTO DEPARTMENT FROM DEPT 6 DEPT TABLE 7 CREATE TABLE DEPT 8 DEPTNO NUMBER (2) NOT NULL, 9 DNAME VARCHAR2 (14), 10 LOC VARCHAR2 (13), 11 CONSTRAINT DEPT PRIMARY KEY PRIMARY KEY (DEPTNO)); 12 INSERT INTO DEPT VALUES (10, ACCOUNTING,NEW YORK 13 INSERT INTO DEPT VALUES (20, RESEARCH, DALLAS) 14 INSERT INTO DEPT VALUES (30, SALES, CHICAGO) 15 INSERT INTO DEPT VALUES (40, OPERATIONS, BOSTON) 16 17 *Create the EMPLOYEE table based on the following table chart: Column Name ID LAST_NAME FIRST_NAME DEPT_ID 18 Data Type Number Varchar2 Varchar2 Number Length 7 25 25 7*/ 19 CREATE TABLE EMPLOYEE ( 20 ID NUMBER (7) NOT NULL, 21 LAST NAME VARCHAR2 (25), 22 FIRST NAME VARCHAR2 (25) , 23 DEPT ID NUMBER (7); 24 /*Modify the EMPLOYEE table to allow for longer employee last names. Confirm your modification.*/ 25 ALTER TABLE EMPLOYEE 9 5 4

Add a comment
Know the answer?
Add Answer to:
Lesson 10Create the DEPARTMENT tables based on the following: Column Name   ID      Name Data Type     Number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project...

    Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project name. If the employee never worked on a project, show the names only the name, not the project name. (7pts) Retrieve the names of employees who have worked on the same project at a different location. (7pts) Retrieve the names of employees who have worked on more than two different projects. (7pts) Retrieve the names of employees who manage more than two employees. CREATE...

  • rider_student Column Data Type Description student_id integer the primary key first_name varchar(25) student first name last_name...

    rider_student Column Data Type Description student_id integer the primary key first_name varchar(25) student first name last_name varchar(25) student last name major_id integer the ID of the student's major; a foreign key for the major_id in the rider_major table rider_major Column Data Type Description major_id integer the primary key major_name varchar(50) student first name major_description varchar(100) student last name Use the Tables above to answer the questions. Questions: 1. Write a SQL statement to add a student record to the rider_student...

  • Create an XML document for the Oracle Starter Database Tables (i.e., emp, dept, ord, product, price)....

    Create an XML document for the Oracle Starter Database Tables (i.e., emp, dept, ord, product, price). Each XML document must be in the format as described in the "Mapping tables to XML" section on pg. 1161 (any column that does not have a value can be displayed as empty, e.g., <DEGREE></DEGREE> ). The name for each document will be the name of the table followed by ".xml" as the file extension (e.g., "emp.xml"). Data for the Bonus table: CREATE TABLE...

  • Using the following tables write a sql command: List the full name and the total number...

    Using the following tables write a sql command: List the full name and the total number of transactions handled by the full time employee. Rank your results in descending order on the total number of transactions. Table: MEMBERS Column Data Type Length Precision Scale Nullable MEMBERID NUMBER 4 0 No MFIRST VARCHAR2 25 No MLAST VARCHAR2 25 No STREET VARCHAR2 64 No CITY VARCHAR2 25 . No STATE VARCHAR2 2 . No ZIPCODE NUMBER 0 No CREDITLIMIT NUMBER 7 2...

  • QUESTION 9 You plan to query data using the TRANS_HIST_V view that was created by another...

    QUESTION 9 You plan to query data using the TRANS_HIST_V view that was created by another user in their schema. Which statement is true? A. The Oracle Server will retrieve the view definition from the ALL_VIEWS data dictionary view. B. The Oracle Server will retrieve data, determined by the query criteria, from the TRANS_HIST_V view. C. The Oracle Server will verify whether you have been granted access privileges to the TRANS_HIST_V view. D. The Oracle Server will automatically reset the...

  • Create an XML document for the Oracle Starter Database Tables (i.e., emp, dept, ord, product, price)....

    Create an XML document for the Oracle Starter Database Tables (i.e., emp, dept, ord, product, price). Each XML document must be in the format as described in the "Mapping tables to XML" section on pg. 1161 (any column that does not have a value can be displayed as empty, e.g., <DEGREE></DEGREE> ). The name for each document will be the name of the table followed by ".xml" as the file extension (e.g., "emp.xml"). Data for dept. table CREATE TABLE DEPT...

  • CIS 411w spring 2017 Problem Set 11    1 Log in to your Oracle ApEx account....

    CIS 411w spring 2017 Problem Set 11    1 Log in to your Oracle ApEx account. 2. Create a new table called email with this command: CREATE table email as (SELECT empno, ename||'.'||SUBSTR(JOB,1,2)||'@apex.com' as "EMAIL" from emp); Click à Run to create this table 3. Write a SQL query that JOINS the three tables emp,dept and email. This SQL query will return the empno, ename, job, sal, loc and email for each employee. Use the newer ANSI JOIN syntax rather...

  • SQL Query Question: I have a database with the tables below, data has also been aded...

    SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...

  • Quis -2 EMPLOYEES EMPLOYEE ID NUMBER(6.0 FIRST NAME VARCHAR NTE) CONSTRAINT EMPLASTNAME NN NOT NULL ENA...

    Quis -2 EMPLOYEES EMPLOYEE ID NUMBER(6.0 FIRST NAME VARCHAR NTE) CONSTRAINT EMPLASTNAME NN NOT NULL ENA LAST NAME VARCHAI CONSTRAINT EMPEMAIL NN NOT NULL ENABLE "EMAIL VARCHAR CHARZI29 BYTEL "PHONE NUMBE CONSTRAINT EMP HIRE DATE NN NOT NULL ENABLE "HERE DAT Aaue BYTE) CONS TRAINT EMPJOB NN NOT NULL ENABLE 3o8 MBER3 BYTE) SA OMMISSION PCT NUMBER2.23 "MANAGER 1D NUMBER(6.0), "DEPARTMENT ID NUMBER(4,0) 1. Return the names of employees who have the 2nd highest salary Sεutct 2. For every employee,...

  • IN THE PREVIOUS CHAPTER WE MADE A DATABASE USING OUR LAST NAME AS ITS NAME. QUESTION...

    IN THE PREVIOUS CHAPTER WE MADE A DATABASE USING OUR LAST NAME AS ITS NAME. QUESTION 1 STATES THIS. PLEASE TYPE WHAT NEEDS TO BE TYPED FOR ALL STEPS. THIS USES CODIO a. 1. Connect to the database you created and named in Module One (for example, Jetson). Type after the prompt mysql> a. use (table you named); i. Example: mysql> use Jetson; 2. Create the Employee table using the SQL statement shown here. Press Return after each line. CREATE...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT