To write DDL statement to create the following table named a

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.

Solution

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\'

 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 primar

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site