Question

1. What are three uses for a view? 2. Create a table named COPY_customers from the...

1. What are three uses for a view?

2. Create a table named COPY_customers from the customers table.

3. Use the CREATE or REPLACE option to create a view of all the columns in the COPY_customers table called view_ customers.

4. Use view_ customers to INSERT a row of data into the underlying COPY_customers table. Execute a SELECT * from COPY_customers to verify your DML command.

5. Show the contents of the view_ customers view.

6. Write the statement to create a view including customer_id, customer_last_name, customer_city, and customer_state for all customers who live in OH, NY, and DC.

7. Using your view, write the statement to show the number of customers who live in NY.

8. Write the query to show the name of all your views in your schema. Use the USER_VIEWS. Note that I only need the name of the views

Homework Answers

Answer #1

Table Create

drop table customers;
drop table COPY_customers;


Create table customers(customer_id int Primary key,customer_last_name varchar(40),customer_city varchar(30),customer_state varchar(30));
desc customers;
insert into customers values(101,'Rajgor','OH','Gujrat');
insert into customers values(102,'Viral','NY','Gujrat');
insert into customers values(103,'Navinbhai','DC','Gujrat');
Select * from customers;


/*1 Uses of View */

/* It Provide encapsulation */
/* It Virtual table, not stored permanently */
/* It is used to implement the security mechanism */

/*2 Uses of Old table make new table */
Create table COPY_customers as Select * from customers;
desc COPY_customers;

/*3 Make View */
Create or REPLACE VIEW view_customers as Select * from customers;
Select * from view_customers;


/*4 Insert Row in View */
insert into view_customers values(104,'Paresh','NY','Maharastra');
Select * from view_customers;

/*5 Content of View */
desc view_customers;


/*6 Content of View */
Create View View_Customer_v as Select customer_id,customer_last_name,customer_city,customer_state from customers where customer_city in('OH','NY','DC');
desc View_Customer_v;

/*7 Content of View */
Create View View_Customer_v1 as Select count(*)"Total " from customers where customer_city in('NY');
desc View_Customer_v1;


/*8 All View */

SELECT * FROM DBA_OBJECTS WHERE OBJECT_TYPE = 'VIEW'

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Know the answer?
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
Similar Questions
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno,...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno, model, mileage, owner_name, owner_ph)) Rented (tno, Vno) 5. (i)Write an SQL query, to create the table vehicle with following constraints: Vno should begin with second letter ‘v’; Models are one among Thar, X3. Mileage should be above 18 and below 25. No two records can have same phone (ii) Write an SQL query to retrieve the name of the owner who does owns X3...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL...
EMPLOYEE Field Name EMP_ID EMP_LNAME EMP_MI EMP_FNAME EMP_SEX EMP_AGE EMP_SALARY EMP_HIREDATE DEPT_CODE Table: DEPARTMENT DEPT_CODE BIOL CPTR HIST MATH RELB Data Type Text Text Text Text Text Number Currency Date/Time Text DEPT_TITLE Biology Computer Science History Mathematics Religion    Field Name DEPT_CODE DEPT_TITLE Data Type Text Text INSTRUCTIONS Use SQL commands to create the tables and enter the data shown above using MS Access. Write the following SQL statement given below: 1. 2. 3. 4. 5. 6. 7. 8. 9....
Task 7.1.2. Create a view named nc_jobs which shows all the bookjob information for a job...
Task 7.1.2. Create a view named nc_jobs which shows all the bookjob information for a job with a jobtype of N for publisher with a creditcode of C. CREATE TABLE publishers ( cust_id       CHAR(3) NOT NULL, name        CHAR(10), city        CHAR(10), phone        CHAR(8), creditcode    CHAR(1), primary key (cust_id) ); CREATE TABLE bookjobs ( job_id       CHAR(3) NOT NULL, cust_id       CHAR(3), job_date    DATE, descr CHAR(10), jobtype CHAR(1), primary key (job_id), foreign key...
Time: 10 minutes Objective: Create, view and extract tar archives. Description:  In this activity, the student will...
Time: 10 minutes Objective: Create, view and extract tar archives. Description:  In this activity, the student will use the tar utility to create, view, and extract a tar archive and use it options to name the tar file and view files as they are being archived and extracted. 1.     Start your Linux server virtual machine and sign-on with your individual user ID.  All Activities should begin in your home directory. 2.    Create a directory by typing  mkdir Act6-1 and press Enter.  Switch to this new directory...
-- Table construction (just 1 simplest possible way) CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY,...
-- Table construction (just 1 simplest possible way) CREATE TABLE PetType ( petTypeId VARCHAR(10) PRIMARY KEY, animalType VARCHAR(20), breed VARCHAR(20) ); CREATE TABLE Owner ( ownerId VARCHAR(10) PRIMARY KEY, firstName VARCHAR(20), lastName VARCHAR(20) NOT NULL, homePhoneNumber VARCHAR(20), streetAddress VARCHAR(80), suburb VARCHAR(20), postcode VARCHAR(10) ); CREATE TABLE Pet ( petId VARCHAR(10) PRIMARY KEY, petName VARCHAR(20), sex CHAR(1) CHECK (sex IN ('M', 'F')), petTypeId VARCHAR(10) FOREIGN KEY REFERENCES PetType ); CREATE TABLE PetAndOwner ( ownerId VARCHAR(10), petId VARCHAR(10), PRIMARY KEY (ownerId, petId),...
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a...
SQL DATABASE Task 4 [1.5 marks] Create Index (0.5 marks) Currently, the database only contains a small number of records. However, the data contained within it is expected to grow significantly in the future. Creating indexes on commonly searched columns is a way performance issues can be minimized. Write a command to create an index on student_name column of the student table. Create view – 1 mark Write a command to create a view to list the student ID and...
1. By convention, how are configuration files separated from regular files? (NOTE: A practical effect of...
1. By convention, how are configuration files separated from regular files? (NOTE: A practical effect of the separation is that they are not displayed by the default version of the ls command)                         a. the prefix "rc" (rc.filename)               c. the extension .cfig                         b. a dot (.) at the beginning                    d. by having the SUID bit set 2. The IP address which is reserved for local loopback (equivalent to "localhost") is:                         a. 255.255.255.0                                   c. 192.168.70.1...
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects....
Summary The Ch08_ConstructCo database stores data for a consulting company that tracks all charges to projects. The charges are based on the hours each employee works on each project. The structure and contents of the Ch08_ConstructCo database are shown in Figure P8.1. Use this database to answer the following problems. Database Schema The schema for the Ch08_ConstructCo database is shown below and should be used to answer the next several problems. Click this image to view it in its own...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT