CSC239_Lab02-1 (4)

.doc

School

Rutgers University, Newark *

*We aren’t endorsed by this school

Course

239

Subject

Computer Science

Date

Oct 30, 2023

Type

doc

Pages

5

Uploaded by jackelynbenavides842

Report
Middlesex County College CSC239-60 Computer Science Department Version 5 Lab Assignment Database Concepts Page 1 __________________________________________________________________________________________ Lab #2– Creating And Updating Tables A. Overview 1. This lab will introduce you to creating tables updating them by adding, changing, and deleting table content. 2. You will enter data into the data base table and then display the contents. 3. The SQL activities will then be screen printed and pasted into a word document, saved, and printed. B. SQL Notation: 1. SQL CREATE TABLE Statement: a. Used to create a table in a database. b. Tables are organized into rows and columns; and each table must have a name. c. SQL CREATE TABLE Syntax CREATE TABLE table_name ( column_name1 data_type ( size ), column_name2 data_type ( size ), column_name3 data_type ( size ), .... ); d. Explanation: (1) The column_name parameters specify the names of the columns of the table. (2) The data_type parameter specifies what type of data the column can hold (for example: varchar, integer, decimal, date, etc.). (3) The size parameter specifies the maximum length of the column of the table. e. Example: (1) To create a table called "Persons" that contains five columns: PersonID, LastName, FirstName, Address, and City. (2) Example CREATE TABLE statement: CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) ); (3) Explanation: (a) The PersonID column is of type int and will hold an integer. (b) The LastName, FirstName, Address, and City columns are of type varchar and will hold characters, and the maximum length for these fields is 255 characters
Middlesex County College CSC239-60 Computer Science Department Version 5 Lab Assignment Database Concepts Page 2 __________________________________________________________________________________________ 2. SQL INSERT INTO Statement a. Used to insert new records in a table. b. SQL INSERT INTO Syntax: (1) It is possible to write the INSERT INTO statement in two different formats. (2) The first format does not specify the column names where the data will be inserted, only their values. (a) Syntax: INSERT INTO table_name VALUES ( value1 , value2 , value3 ,...); (b) Example: INSERT INTO Persons VALUES (20,'Bob', 'Brown','123 Smith Street', 'Edison'); (3) The second format specifies both the column names and the values to be inserted. (a) Syntax: INSERT INTO table_name ( column1 , column2 , column3 ,...) VALUES ( value1 , value2 , value3 ,...); (b) Example: INSERT INTO Persons (CustomerName, ContactName, Address, City, State, Zip, Country) VALUES (20,’John’,’Smith’,’123 Miller Street’, 'Edison’); 3. SQL INSERT For Data Only in Specified Columns a. Used to insert data only in specific columns. b. SQL INSERT INTO Syntax: (1) INSERT INTO table_name ( column1 , column2 , column3 ,...) VALUES ( value1 , value2 , value3 ,...); c. Example explanation: (1) The following SQL statement will insert a new row, but only insert data in the "CustomerName", "City", and "Country" columns: (2) Example INSERT INTO Persons (PersonID, FirstName, LastName, Address, City) VALUES (30,'John','Smith','123 Miller Street', 'Edison'); 4. SQL UPDATE Statement: a. Used to update existing records in a table. b. SQL UPDATE Syntax: UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value; c. Example: (1) To update the customer "Alan Alda" with a new contact person and city. (2) Use the following SQL statement: UPDATE Persons SET FirstName='Johny' WHERE FirstName = 'John'; d. Update Warning: (1) Be careful when updating records. (2) If the WHERE clause would have been omitted, many records could have been accidentally updated.
Middlesex County College CSC239-60 Computer Science Department Version 5 Lab Assignment Database Concepts Page 3 __________________________________________________________________________________________ 5. The SQL DELETE Statement for particular data: a. Used to delete rows in a table. b. SQL DELETE Syntax: DELETE FROM table_name WHERE some_column=some_value c. Example (1) To delete the customer "Alan Alda" from the "Customers" table. (2) Use the following SQL statement: DELETE FROM Persons WHERE FirstName = 'ABC'; 6. The SQL Delete Statement to delete all data: a. Used to delete all rows in a table without deleting the table. b. This means that the table structure, attributes, and indexes will be intact. c. SQL DELETE Syntax: DELETE FROM table_name ; or DELETE * FROM table_name ; d. Be very careful when deleting records because you cannot undo this statement. 7. The SQL DROP TABLE Statement: a. Used to delete a table. b. SQL DROP TABLE Syntax: DROP TABLE table_name 8. The DROP DATABASE Statement: a. Used to delete a database. b. DROP DATABASE Syntax: DROP DATABASE database_name 9. The TRUNCATE TABLE Statement: a. Used to delete the data inside the table, and not delete the table itself b. TRUNCATE TABLE Syntax: TRUNCATE TABLE table_name C. Activity: 1. Using a web browser, go to the website: academy.oracle.com 2. Select the “Sign In / Register” option. 3. Select the Application Express option to log in 4. Log into Application Express. 5. Select the “SQL Workshop” button. 6. On right side of the window, select “Table” from the “Create Object” group on the right. 7. Click on the Next button. 8. In the Create Table window, click in the textbox for the table name
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: How can you show how efficiency ratios can be used to determine the best way to conduct the…
Q: 17. x 1-y, x= y²- 1
Q: Order 7 of the following sentences so that they form a logical proof by contrapositive of the…
Q: Create your own SN1 reaction and label the steps 1) heterolysis of leaving group 2) coordination of…
Q: Find the regression equation, letting the first variable be the predictor (x) variable. Using the…
Q: Please find the stoichiometric balance for the reaction equation Zn(s) + H+(aq) → Zn2+(aq) + H2(g)
Q: Use the parametric equations of an ellipse x = 4 cos 0 y = 13 sin 0 0≤0 ≤2T to find the area that it…
Q: The one-to-one functions g and h are defined as follows. g={(-4, 1), (2, 7), (3, 6), (5, 8), (8, 3)}…
Q: Two companies, Wonka and Gekko, each decide whether to produce a good quality product or a poor…
Q: An equilateral triangular plate with sides 8 m is submerged vertically in water so that the base is…
Q: Are wages more sticky upwards or downwards? Why? Explain.
Q: Differentiate the following function 3 U = ²³² √² + ² + 2 u= +2√+³
Q: what is the definition of prescription privileges and Medical staff privileges withinContemporary…
Q: 1 Determine the average value of f(x) over the interval from x= a to x = b, where f(x) = 1 a = and b…
Q: Kate has just completed her first year running Kate’s Cards. She has been preparing monthly income…
Q: Write a query to create the zoo database. Write queries to create the tables. Be sure to include…
Q: Find all points x where the function g(x)=|x+4|−|x−6| is not differentiable. Separate multiple…
Q: What populations(doctors or patients) is most affected by prescription privileges ? and why Waht…
Q: An asset used in a 4-year project falls in the 5-year MACRS class for tax purposes. The asset has an…
Q: 36. Drug pharmacokinetics A patient is injected with a drug every 12 hours. Immediately before each…
Q: sing put-call parity, if the price of an At-the-Money Call option maturing in 1 day is $3.14, what…
Q: 6.1 (3) Sketch the region enclosed by the given curves. Draw a typical approximating rectangle and…