Question

1. Answer the questions with respect to the table below. users gender id name age occ_id city_id John 25 M 3 1 2. Sara 20 F 3(b) [2.5+2.5+5) Write query to make a copy of users table known as users_new. Write query to insert all columns of users

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

1.

CREATE TABLE users_new LIKE users;

2.

INSERT INTO users_new SELECT * FROM users;

3.

ALTER TABLE users ADD salary INT;

UPDATE users, occupation
SET salary =
(
case
when occupation.name = 'Software Engineer' then 80000
when occupation.name = 'Accountant' then 75000
when occupation.name = 'Pharmacist' then 90000
end
)
WHERE users.occ_id= occupation.id;

Add a comment
Know the answer?
Add Answer to:
1. Answer the questions with respect to the table below. users gender id name age occ_id...
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
  • SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male...

    SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male 4500 Canada 3 Pam Female 5500 USA 4 Sara Female 4000 Canada 5 Todd Male 3500 Canada 6 Mary Female 5000 UK 7 Ben Male 6500 UK 8 Elizabeth Female 7000 USA 9 Tom Male 5500 UK 10 Ron Male 5000 USA Given the EMPLOYEE table above, write a query that would produce the output below. COUNTRY    GENDER     Total Salary ---------- ---------- ------------ Canada     Female             4000 Canada     Male               8000 UK         Female             5000...

  • SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male...

    SQL/Oracle EMPLOYEE Table ID NAME GENDER SALARY COUNTRY 1 Mark Male 5000 USA 2 John Male 4500 Canada 3 Pam Female 5500 USA 4 Sara Female 4000 Canada 5 Todd Male 3500 Canada 6 Mary Female 5000 UK 7 Ben Male 6500 UK 8 Elizabeth Female 7000 USA 9 Tom Male 5500 UK 10 Ron Male 5000 USA Given the EMPLOYEE table above, write a query that would produce the output below. COUNTRY    GENDER     Total Salary ---------- ---------- ------------ Canada     Female             4000 Canada     Male               8000 Canada     NULL              12000...

  • Assume the table below is a client table: Client ID Client Name Client Services Client City...

    Assume the table below is a client table: Client ID Client Name Client Services Client City Client Revenue Client type (active/inactive) 1 BK Associates Commercial Toronto 230,000 active 6 Bick Industrial Dallas 679,000 inactive 19 TPH Government Atlanta 986,000 active 12 Crow Industrial Phoenix 126,000 inactive 56 TX Electric Industrial Portland 564,000 active 42 GRB Government Omaha 437,000 inactive 98 LB&B Commercial Toronto 990,000 active 44 H&P Commercial Denver 122,000 active You are asked to implement a C# console application...

  • Please answer the following questions bles Charts SmartArtReview Paragraph AaBbCcDdEe Normal Name: ID Name: ID: Question...

    Please answer the following questions bles Charts SmartArtReview Paragraph AaBbCcDdEe Normal Name: ID Name: ID: Question (1) For the following periodic signal, (5p 2) Write os os5 2WY 1) Determine the Fourier series coefficient as an b Sec 1 Pages 1 of 4 Words: 63 of 83 L 25

  • 1. Given the table above, write an SQL Query that will select only those individuals that...

    1. Given the table above, write an SQL Query that will select only those individuals that scored 800 or higher, sorted by last name in ascending order. 2. Given the table above, write an SQL Query that will add a new entry for John Smith with a score of 834. The field id is auto incrementing. 3. Given the data below, write an SQL Query that will delete any values where the score is below 740. id Fname Lname Score...

  • Part II: Group-by and subqueries The following questions use the Spy and Sailors database. Write the...

    Part II: Group-by and subqueries The following questions use the Spy and Sailors database. Write the SQL for the following queries. 1) List the sailor id and name for each sailor who has reserved two different red boats. Make sure that each sailor id/name is listed at most once. You must use group by/having. 2) List the missions and their status for each team. 3) For each country in agent, list the country and the count of agents in the...

  • 1.Write a PHP function that generates a random email. 2.Write a PHP function that generates a...

    1.Write a PHP function that generates a random email. 2.Write a PHP function that generates a random password given the length as a parameter. 3. Run a query that will generate a database named lab4 b. 4.Run a query that will create a table named users, the table will only have three columns, email TEXT and password TEXT, ID INTEGER NOT NULL AUTO_INCREMENT. ID will be the primary key that will be generated for us automatically based on the record...

  • SQL Homework 1. For each reservation, list the reservation ID, trip ID, customer number, and customer...

    SQL Homework 1. For each reservation, list the reservation ID, trip ID, customer number, and customer last name. Order the results by customer last name. 2. For each reservation for customer Ryan Goff, list the reservation ID, trip ID, and number of persons. 3. List the trip name of each trip that has Miles Abrams as a guide. 4. List the trip name of each trip that has the type Biking and that has Rita Boyers as a guide. 5....

  • QUESTION: (Answer in SQL) Write an SQL query to find all pairs of users (A,B) such...

    QUESTION: (Answer in SQL) Write an SQL query to find all pairs of users (A,B) such that both A and B have blurted on a common topic but A is not following B. Your query should print the names of A and B in that order. BACKGROUND INFO: Users can post their thoughts in form of short messages that we call “blurts”. When signing up, users need to provide their email and a password of their choice. In addition, they...

  • HELP DATABASE QU Question 1: Think About the relational database table data as given below, write...

    HELP DATABASE QU Question 1: Think About the relational database table data as given below, write the following queries in Oracle SQL. Company (Cid, Cname, City, Budget, Branch) Department (Deptno, Dname, Building, Cname) Employee (Ename, Deptno, Street, City, Phone, Salary) Works (Ename, Deptno, Hire_date) Location (Cname, Location ) 1. Write Query to Create the Company table, suggest appropriate data type of each attribute, consider that there should be a name for each company. 2. Find employee name/names who live in...

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