To write DDL statement to create the following table named a
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\'
