SQL Homework exercises:
1.
Write INSERT statements that add two rows to the Members table for member IDs 1 and 2, two rows to the Groups table for group IDs 1 and 2, and three rows to the Group_Membership table: one row for member 1 and group 2; one for member 2 and group 1; and one for member 2 and group 2. Then, write a SELECT statement that joins the three tables and retrieves the group name, member last name, and member first name.
2.
Write an INSERT statement that adds another row to the Groups table. This statement should use the NEXTVAL pseudo column to get the value for the next group ID from the sequence that you created in exercise 1. Then, write a SELECT statement that gets all of the data for all of the rows in the Groups table to make sure your sequence worked correctly.
3.
Write an ALTER TABLE statement that modifies the Groups table so the group name in each row has to be unique. Then, re-run the INSERT statement that you used in exercise 2 to make sure this works.
Members( mem_id, first_name, last_name)
Groups( grp_id , name)
Group_Mmebership( mem_id, grp_id)
1.
INSERT INTO Members ( mem_id, first_name, last_name)
VALUES ( 1 , 'Tom', 'Kala' );
INSERT INTO Members ( mem_id, first_name, last_name)
VALUES ( 2 , 'Matti', 'Erichsen' );
INSERT INTO Groups ( grp_id , name)
VALUES (1, 'abc');
INSERT INTO Groups ( grp_id , name)
VALUES (1, 'def');
INSERT INTO Group_Membership ( mem_id, grp_id )
VALUES (1, 2);
INSERT INTO Group_Membership ( mem_id, grp_id )
VALUES (2, 1);
INSERT INTO Group_Membership ( mem_id, grp_id )
VALUES (2, 2);
SELECT G.name, M.first_name, M.last_name
FROM Groups_Memebership P
INNER JOIN Members M ON M.mem_id = P.mem_id
INNER JOIN Groups G ON G.grp_id = P.grp_id;
2.
INSERT INTO Groups ( grp_id , name)
VALUES ( grp_seq.NEXTVAL, 'ijk');
SELECT * FROM Groups;
3.
ALTER TABLE Groups
ADD UNIQUE (name);
INSERT INTO Groups ( grp_id , name)
VALUES ( grp_seq.NEXTVAL, 'ijk');
SQL Homework exercises: 1. Write INSERT statements that add two rows to the Members table for...
this is sql developer question I just need the format of how to answer question! Create sequences (2) that can be used to number the member ID and group ID values starting with 3 (since you already have 1 and 2). Write an INSERT statement that adds another row to the Groups table, make up a group name. Use the NEXTVAL pseudo column to get the value for the next group ID from the sequence that you created in #5....
3. Write a script that adds rows to the database that you created in exercise 2. Add two rows to the Users and Products tables. Add three rows to the Downloads table: one row for user 1 and product 2; one row for user 2 and product 1; and one row for user 2 and product 2. Use the SYSDATE function to insert the current date into the download_date column. Use the sequences created in the previous exercise to get...
2. Write a script that implements the following design: In the Downloads table, the user_id and product_id columns are the foreign keys. Create these tables in the ex schema. Create the sequences for the user_id, download_id, and product_id columns. Include a PL/SQL script to drop the table or sequence if it already exists. Include any indexes that you think are necessary. 3. Write a script that adds rows to the database that you created in exercise 2. Add two rows...
1. Write an INSERT statement that adds this row to the Categories table: CategoryName: Brass Code the INSERT statement so SQL Server automatically generates the value for the CategoryID column. 2. Write an UPDATE statement that modifies the row you just added to the Categories table. This statement should change the Category Name column to “Woodwinds”, and it should use the CategoryID column to identify the row. 3.Write an INSERT statement that adds this row to the Products table: ProductID:...
WRITE A SQL QUERY SQL SERVER Write a SELECT statement that returns one column from the Customers table named FullName that joins the LastName and FirstName columns. -- Format this column with the last name, a comma, a space, and the first name like this: -- Doe, John -- Sort the result set by last name in ascending sequence. -- Return only the contacts whose last name begins with a letter from M to Z. -- ...
1.Write a pl/SQL block that selects all the rows from the A2order table and prints them to screen. THIS CAN BE EASILY DONE USING AGGREGATE FUNCTIONS, BUT YOU MUST NOT USE AGGREGATE FUNCTIONS IN THIS ASSIGNMENT 2. 2.Write a pl/sql block that deletes the orders from the A2order table that were ordered after the order that has the highest order_price (Order_date will tell you when a row was entered). YOU MUST USE BULK OPERATIONS FOR THIS CODE 3. Write a...
Write SQL authorization statements on the employee table as per the following requirements: Employee (id, name, job_name, dept_name, salary) - You have three managers with manager1, manager2 and manager3 user ids. All of them are members of the role manager. - All managers have the same privileges: select, insert, update, delete. - No managers can transfer his privileges on the employee table.
l want to insert statement inside the table student on My SQL
program the latest version but there is an error l am not able
determine how to applied or insert a row as:
Steps
In each of these queries you’re shown the columns to display in
your result. Make your column headers look exactly like the example
shown. All these queries use the Starter database.
0. Even if you downloaded it for the previous assignment, to make
sure you...
1) Write or select the correct SQL statement that satisfies the following case: Change record with value 'Nick' to 'Cuba' for the 'Last Name' attribute in the table 'Vendors' A. UPDATE VENDORS SET LAST_NAME='CUBA' WHERE LAST_NAME=NICK B.INSERT INTO LAST_NAME VALUES("NICK"); C.INSERT INTO 'NICK' VALUES('VENDORS'); D. INSERT INTO VENDORS WHERE LAST_NAME="NICK" 2) Write or select the correct SQL statement that satisfies the following case: Change record with value 'Gary' to 'Jada' for the 'Style' attribute in the table 'Invoice_Line' A. INSERT...
Insert the bottom two rows to each table we made in class and update the two in gray in stock and product tables. Provide your SQL code in notepad or word. You can include a screen shot of your select statements showing database populated with your name in ure showing your account Product Product Name Manufacturer 1 102 103 509 Product Product Description Ergonomic keyboard with rest pad HP Model 3456 5x7 inch monitor with stylus Series 5 Pink 32G...