Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To write DDL statement to create the following table named as hw2tusers. Userid

ID: 3793294 • Letter: T

Question

To write DDL statement to create the following table named as hw2tusers. Userid will be the primary key (notice that it is underlined to meant to be the primary key). Password should not be null, the default value of status should be 1. (In real world, the password field should be encrypted, but we use plain password to mainly illustrate database problems.) Write DML SQL statements to insert above records into the above table (populate the table). Write a single DML SQL statement to update status to 2 for a11 records. Write a DML SQL statement to update the uscr2 record's name to kerly by matching user2 with userid in the where subclause. Write a DML SQL statement to delete user4 record.

Explanation / Answer

1.
CREATE TABLE hw2tusers
(
userid varchar2(10) PRIMARY KEY,
password varchar2(10) NOT NULL,
status number DEFAULT 1,
name varchar2(10)
);

2. Write DML SQL statements to insert above revords into the above table.
INSERT INTO hw2tusers VALUES ('user1', 666666, 1, 'john');
INSERT INTO hw2tusers VALUES ('user2', 555555, 1, 'Kelly');
INSERT INTO hw2tusers VALUES ('user3', 444444, 1, 'james');
INSERT INTO hw2tusers VALUES ('user4', 333333, 1, 'Kelly');

3. Write a single DML SQL statement to update status to 2 for all records.
UPDATE hw2tusers
SET status = 2;

4. Write a DML SQL statement to update the user2 record's name to kerly by matching user2
with userid in the where subclause.
UPDATE hw2tusers
SET name = 'kerly'
WHERE userid = 'user2'

5. Write a DML SQL statement to delete user4 record.
DELETE FROM hw2tusers
WHERE userid = 'user4'

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote