Question

A Guide to SQL Questions 1. How do you create a table using SQL? 2. How...

A Guide to SQL Questions

1. How do you create a table using SQL?

2. How do you delete a table using SQL?

3. What are the common data types used to define columns using SQL?

4. Identify the best data type to use to store the following data in Oracle, in SQL Server, and in Access:

   a. The month, day, and year that an employee was hired

   b. An employee’s Social Security number

   c. The department in which an employee worksd. An employee’s hourly pay rate

5. Identify the following column names as valid or invalid in Oracle:

   a. COMMISSIONRATE

   b. POSTAL_CODE_5CHAR

   c. SHIP TO ADDRESS

   d. INVOICE-NUMBER

6. What is a null value? How do you use SQL to identify columns that cannot accept null values?

7. Which SQL command do you use to add a row to a table?

8. Which SQL command do you use to view the data in a table?

9. Which SQL command do you use to change the value in a column in a table?

10. Which SQL command do you use to delete rows from a table?

11. How do you display the columns in a table and their characteristics in Oracle?

12. Explain the difference between the CHAR data type and the VARCHAR data type. Use the Internet to find examples of when to use VARCHAR and when to use CHAR. Be sure to cite the URL(s) that provided the examples as references at the end of your document.

13. Use the Internet to research BOOLEAN data types. What is a BOOLEAN data type and what is it called in Oracle, SQL Server, and Access? Be sure to cite the URL(s) that provided the information at the end of your document.

Homework Answers

Answer #1

1) CREATE TABLE <table_name> ( *<Column_name> <Data_Type>);

2) DROP TABLE <table_name>;

3) int, varchar, varchar2, date, time, datetime, etc

4) (a) datetime (b) int (c) varchar2

5) (c) and (d) are invalid

6) A null value is a value which is defined when a variable does not contain any value. The SQL statement is

SELECT <column_names>
FROM <table_name>
WHERE <column_name> IS NOT NULL;

7) INSERT INTO table(column1,...) VALUES(value1, ....);

8) SELECT column1, column2, ...FROM table_name;

9) UPDATE table_name SET column1 = value1 WHERE condition;

10) DELETE Product WHERE column_name=value

11) SELECT * FROM sys.columns WHERE object_id = OBJECT_ID('dbo.table_name')

12) varchar is variable length whereas char is fixed length.

13) ORACLE - CHAR(1) is used to store Y or N ; SQL SERVER - BIT is used; ACCESS - BIT is used

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
Do 1: In Oracle Apex, create a table named “employees” give the table the following columns:...
Do 1: In Oracle Apex, create a table named “employees” give the table the following columns: Column name data type employeeID Number employeeName Varchar2(50) salary Number datehired Date Create the database script that builds the above table
If you had to create a new table in your database called EMPLOYEE and load data...
If you had to create a new table in your database called EMPLOYEE and load data into it using SQL commands below. CREATE TABLE EMPLOYEE (               EMP_ID INT PRIMARY KEY,               EMP_FNAME VARCHAR(200) NOT NULL,               EMP_LNAME VARCHAR(200) NOT NULL,               EMP_CITY VARCHAR(500) NULL ,               EMP_STATE VARCHAR(20) NULL ) INSERT INTO EMPLOYEE VALUE (1, ‘Kevin’, ‘Lailnay’, NULL, ‘PA’) INSERT INTO EMPLOYEE VALUE (2, ‘Sarita, ‘Kawn, ‘Princeton’,’NJ’) INSERT INTO EMPLOYEE VALUE (2, ‘Gloria, ‘Pitts, ‘Allentown, ‘PA’) INSERT INTO EMPLOYEE...
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...
PLEASE USE MICROSOFT SQL SERVER MANAGEMENT STUDIO 18 The purpose of this task is to create...
PLEASE USE MICROSOFT SQL SERVER MANAGEMENT STUDIO 18 The purpose of this task is to create a student table such that it has 2 partitions. One that will include all student id's through 500 and a second one that will include all student id's above 500. StudentID                   int           StudentName              varchar(30) *StudentID should be a a primary key. **StudentName should be required. Do you not use the master filegroup. Each partition should be associated with a different physical file. Use any...
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...
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...
Subtask 10.2.1 Run the following JOIN of two tables which has two restrictions. Examine the output...
Subtask 10.2.1 Run the following JOIN of two tables which has two restrictions. Examine the output – is this what you expect? Prefix the query with “EXPLAIN EXTENDED” and review the output. SQL EXPLAIN EXTENDED SELECT * FROM Orders NATURAL JOIN Order_Details WHERE QuotedPrice > 1000 AND OrderDate BETWEEN '2012-10-01' AND '2012-10-31'; Examine the query plan output with the help of the column explanations given above. Describe in your own words how the DBMS is fetching the rows. For each...
-- Drop the tables if they existDROP TABLE REP CASCADE CONSTRAINTS;DROP TABLE CUSTOMER CASCADE CONSTRAINTS;DROP TABLE...
-- Drop the tables if they existDROP TABLE REP CASCADE CONSTRAINTS;DROP TABLE CUSTOMER CASCADE CONSTRAINTS;DROP TABLE ORDERS CASCADE CONSTRAINTS;DROP TABLE ITEM CASCADE CONSTRAINTS;DROP TABLE ORDER_LINE CASCADE CONSTRAINTS;-- You are to change CUSTOMER to CUSTOMERS for the Colonial database to avoid conflict with the CUSTOMER table in Tal.-- Create the tablesCREATE TABLE REP(REP_NUM CHAR(2) PRIMARY KEY,LAST_NAME CHAR(15),FIRST_NAME CHAR(15),STREET CHAR(15),CITY CHAR(15),STATE CHAR(2),POSTAL_CODE CHAR(5),COMMISSION DECIMAL(7,2),RATE DECIMAL(3,2) );CREATE TABLE CUSTOMER(CUSTOMER_NUM CHAR(3) PRIMARY KEY,CUSTOMER_NAME CHAR(35) NOT NULL,STREET CHAR(20),CITY CHAR(15),STATE CHAR(2),POSTAL_CODE CHAR(5),BALANCE DECIMAL(8,2),CREDIT_LIMIT DECIMAL(8,2),REP_NUM CHAR(2) );CREATE...
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....
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures....
Create 2 stored procedures: sp_AddNewUser and sp_AddNewRole. Use the ManyToMany script as your base table structures. The stored procedure should accept the parameters needed to input the data for each table. NOTE: You do not need to input the UserID or RoleID. These are surrogate keys and the system automatically inserts them when you insert a row in the tables.   On execution, the stored procedure should check the database to see if the user exists, if so, return a message...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT