Question

1. Create a new table called EmpDB based on emp table but includes only fields: emp mgr, copy data of employees. 2. Create a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer

1.

Create table based on another table by copying data from selected columns

Syntax

CREATE TABLE new_table
  AS (SELECT column_1, column2, ... column_n
      FROM old_table);

SQL code for the given question based on the above syntax is

CREATE TABLE EmpDB
  AS (SELECT empno, ename, mgr
      FROM emp);

2.

SQL code to create device table is

CREATE TABLE device
( No number(3) PRIMARY KEY,
  Name varchar2(10) NOT NULL,
  ESSN number(4)
);

3.

SQL code to make sure ID is in between 100 and 999 is

ALTER TABLE device
  ADD CHECK (No BETWEEN 100 AND 999);

4.

SQL code to make ESSN as foreign key to the empno in EmpDB is

ALTER TABLE device
  ADD FOREIGN KEY(ESSN) REFERENCES EmpDB(empno);
Add a comment
Know the answer?
Add Answer to:
1. Create a new table called EmpDB based on emp table but includes only fields: emp mgr, copy dat...
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
  • 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...

  • 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...

  • (3.5 Marks) Create the table CAR and create the fields with primary key Field Name Data...

    (3.5 Marks) Create the table CAR and create the fields with primary key Field Name Data type Size Constraint A2.1 Name Model Price MED Varchar2 25 Not nul Number 10 Primary key Number 10,2 Date Write a SQL Query to display all car details from the "CAR" table and display the Name in lowercase in a new column with the column name as Newname. (3.5 Marks) A2.2 Name Model Price MFD Mazda 456 7760.2523-12-2018 Kia 127 4050.1 30-11-2019 Toyota 443...

  • Create a table tHW2_1_xxxx with the following fields and their data types (id:int, auto increment, Name:...

    Create a table tHW2_1_xxxx with the following fields and their data types (id:int, auto increment, Name: varchar(10), birthday: date, annual_salary: float, bno: varchar(8)), where id is primary key and bno is a foreign key to the branchno column of Branch table in the dreamhome database. All fields cannot be null. then insert five records into your tHW2_1_xxxx table. All the name, birthday, should be different.

  • drop table department cascade constraints; create table department ( Dname   varchar2(15)   not null, Dnumber int   not...

    drop table department cascade constraints; create table department ( Dname   varchar2(15)   not null, Dnumber int   not null, Mgr_ssn   char(9)   not null, mgr_start_date   Date, primary key (Dnumber), Unique    (Dname)); insert into DEPARTMENT values ('Research', '5', '333445555', '22-May-1988'); insert into DEPARTMENT values ('Administration', '4', '987654321', '01-Jan-1995'); insert into DEPARTMENT values ('Headquarters', '1', '888665555', '19-Jun-1981'); drop table employee cascade constraints; create table employee ( Fname   varchar2(15) not null, Minit   char(1), Lname   varchar2(15) not null, Ssn   char(9), Bdate   date, Address   varchar2(30), Sex   char(1),...

  • DROP TABLE EMPLOYEE; DROP TABLE JOB; DROP TABLE EMP; DROP TABLE EMP_1; DROP TABLE EMP_2; CREATE...

    DROP TABLE EMPLOYEE; DROP TABLE JOB; DROP TABLE EMP; DROP TABLE EMP_1; DROP TABLE EMP_2; CREATE TABLE JOB(JOB_CODE CHAR (3) PRIMARY KEY, JOB_DESCRIPTION VARCHAR (20) NOT NULL,JOB_CHG_HOUR NUMBER (5,2) NOT NULL,JOB_LAST_UPDATE DATE NOT NULL); INSERT INTO JOB VALUES('500','Programmer','35.75','20-Nov-2017'); INSERT INTO JOB VALUES('501','System Analyst','96.75','20-Nov-2017'); INSERT INTO JOB VALUES('502','Database Designer','125.00','24-Mar-2018'); CREATE TABLE EMPLOYEE(EMP_NUM CHAR (3) PRIMARY KEY,EMP_LNAME VARCHAR (15) NOT NULL,EMP_FNAME VARCHAR (15) NOT NULL, EMP_INITIAL CHAR (1),EMP_HIREDATE DATE NOT NULL,JOB_CODE CHAR (3), EMP_YEARS NUMBER (2),FOREIGN KEY (JOB_CODE) REFERENCES JOB (JOB_CODE)); INSERT...

  • CREATE TABLE DEPT ( DEPTNO INTEGER NOT NULL, DNAME VARCHAR(14), LOC VARCHAR(13), PRIMARY KEY (DEPTNO)); INSERT...

    CREATE TABLE DEPT ( DEPTNO INTEGER NOT NULL, DNAME VARCHAR(14), LOC VARCHAR(13), PRIMARY KEY (DEPTNO)); INSERT INTO DEPT VALUES (10,'SPORTS','NEW YORK'); INSERT INTO DEPT VALUES (20,'HOME','DALLAS'); INSERT INTO DEPT VALUES (30,'OUTDOOR','CHICAGO'); INSERT INTO DEPT VALUES (40,'CLOTHING','BOSTON'); CREATE TABLE EMP ( EMPNO INTEGER NOT NULL, ENAME VARCHAR(10), JOB VARCHAR(9), MGR INTEGER, SAL FLOAT, COMM FLOAT, DEPTNO INTEGER NOT NULL, FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO), FOREIGN KEY (MGR) REFERENCES EMP(EMPNO), PRIMARY KEY (EMPNO)); INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL, 5000,NULL,10); INSERT INTO...

  • -- echo Building demo tables. Please wait. DROP TABLE EMP CASCADE CONSTRAINTS; DROP TABLE DEPT; DROP...

    -- echo Building demo tables. Please wait. DROP TABLE EMP CASCADE CONSTRAINTS; DROP TABLE DEPT; DROP TABLE SALGRADE; DROP TABLE Prod CASCADE CONSTRAINTS; DROP TABLE Vend; CREATE TABLE DEPT ( DEPTNO NUMBER(2) NOT NULL, DNAME CHAR(14), LOC CHAR(13), CONSTRAINT DEPT_PRIMARY_KEY PRIMARY KEY (DEPTNO)); INSERT INTO DEPT VALUES (10,'ACCOUNTING','NEW YORK'); INSERT INTO DEPT VALUES (20,'RESEARCH','DALLAS'); INSERT INTO DEPT VALUES (30,'SALES','CHICAGO'); INSERT INTO DEPT VALUES (40,'OPERATIONS','BOSTON'); CREATE TABLE EMP ( EMPNO NUMBER(4) NOT NULL, ENAME CHAR(10), JOB CHAR(9), MGR NUMBER(4) CONSTRAINT EMP_SELF_KEY...

  • Based on the CREATE TABLE statements, make an ER model of the database. Give suitable names...

    Based on the CREATE TABLE statements, make an ER model of the database. Give suitable names to the relationships. (Remember cardinality and participation constraints.) The diagram must use either the notation used in the textbook (and the lectures) or the crow’s foot notation. To save you some time: There are a few tables that include the following address fields: Address, City, State, Country and PostalCode (and the same fields with the prefix Billing-). You are allowed to replace these attributes...

  • Maureen decided to create a pivot table in a new worksheet using bracelet pivot table as...

    Maureen decided to create a pivot table in a new worksheet using bracelet pivot table as 4. Total Row should automatically total the values in the 2020 field.) Maureen decides to create a PivotTable to allow her to better manipulate and filter the Braceletsales table data. Create a PivotTable based on the Braceletsales table in a new worksheet using Bracelet PivotTable as the worksheet name. Update the PivotTable as described below so that it matches Final Figure 1: Add the...

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