Code in sql/oracle
8. What departments have no employees and what employees have no departments. Show the result of the question through ONLY one query/SELECT statement. Do not write two separate select statements.
To get results we can use full outer join. Full outer join. Full outer join gets all data from left table and matching data of right table and also remaining data of right table. Below is query
SELECT d.department_no,e.employee_id FROM Department d FULL OUTER JOIN employees e ON d.department_id=e.department_id WHERE e.employee_id IS NULL or d.department_id IS NULL;
--department id null provide employees having no dept.
-- employees id null provide department having no employee
Code in sql/oracle 8. What departments have no employees and what employees have no departments. Show the result of the question through ONLY one query/SELECT statement. Do not write two separate sele...
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. -- ...
In oracle pl/sql do not copy and paste from another answered question. Create a common user c##admin query you used to create the user screenshots to prove that user was created, can connect and can create tables and insert data. Use system account to create a table TEST_TABLE_SYSTEM with at least one column and add at least one row. Do not forget to commit. query you used to create the table screenshots to show the content As c##admin try to...
BONUS QUESTION: Suppose you have two tables, EMPLOYEES with primary key employee_ID, and DEPARTMENTS with primary key department_ID. Assume each department may have many employees, but each employee is only assigned one department. What would be the correct SQL syntax for retrieving data from both tables? (HINT: You must find out what is the foreign key) A. SELECT employee_ID, employee_name, department_ID, department_location FROM Employees JOIN Departments ON Employees.employee_ID = Departments.employee_ID; B. SELECT employee_ID, employee_name, department_ID, department_location FROM Employees JOIN Departments...
Question 3. SQL. In addition to the lecture notes, you should also study by yourself the SQL*Plus tutorial on Canvas (the Oracle section) and other resources for Oracle syntax and useful functions. The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, dept name, state, postcode) ACADEMIC(acnum, deptnum*, famname, give name, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(field num, id, title) INTEREST(field num*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one...
Question 3. SQL (5 points). In addition to the lecture notes, you should also study by yourself the SQL Plus tutorial on Canvas (the Oracle section) and other resources for Oracle syntax and useful functions. The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*. acnum) FIELD(fieldnum, id, title) INTEREST(fieldnum* acnum*, descrip) Some notes on the Academics database An academic department belongs to one institution...
Oracle 12c: SQL Joan Casteel ISBN: 978-1-305-25103-8 Chapter 12 Case Study: City Jail Make sure you have run the CityJail_8.sql script from Chapter 8. This script makes all database objects available for completing this case study. The city's Crime Analysis unit has submitted the following data requests. Provide the SQL statements using subqueries to satisfy the requests. Test the statements and show execution results. Use a sql sub-query statement to answer the following: (Please provide correct answer for questions 6...
QUESTION 5 Suppose there are two tables: A and B. and we run command SELECT * from A LEFT JOIN B on A.orderid = B.orderid. What would be the code output? only the records from table A where tables A and B have the same orderid only the records from table B where tables A and B have the same orderid the complete set of records from table A, along with the matching records (depending on the availability) from table...
What happens when you try to compile and run the following code? String query = "INSERT INTO Invoices (InvoiceDate InvoiceTotal) " + "VALUES ('2/10/01', '443.55')"; Statement statement = connection.createStatement(); statement.executeUpdate(query); a. A SQLException is thrown at runtime because the executeUpdate method can’t accept a String object. b. A SQLException is thrown at runtime because the SQL statement is coded incorrectly. c. An error occurs at compile time because the SQL statement is coded incorrectly. d. This code compiles and...
Thumbs up for the Correct answer with all
steps
For the questions below, write the SQL statement and also answer the question if requested. You need to show the execution result of each SQL statement. 1. Create a sequence object (named with SalespersonIDSeq) which starts with 11, is increased by 1 with nocycle 2. Insert two new salesperson records below into Salesperson _T table. number generated using SalespersonIDSeq object For SalespersonID, use a sequence <SalespersonName: Brandon Young, SalespersonCity: Fort Wayne,...
(Using Oracle SQL) How do I
find the primary key of this table? And then how do I consequently
drop the primary key from the table?
Edit: I was already give this code and it did not work
select constraint_name,constraint_type from user_constraint
where table_name='CUSTOMER';
Q7 (10 Points) Use ONE SQL statement to find out the name of the primary key constraint defined on Customer table. (Your SQL should return something like SYS_C0021715, numbers on your account may differ.) Then use...