0% found this document useful (0 votes)
7 views1 page

Make Sure To Replace 'VARCHAR2' and 'NUMBER' With Appropriate Data Types Based On Your DBMS

1 chapter ada

Uploaded by

Geetha A L
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Make Sure To Replace 'VARCHAR2' and 'NUMBER' With Appropriate Data Types Based On Your DBMS

1 chapter ada

Uploaded by

Geetha A L
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

-- 1.

Create a user and grant all permissions to the user

CREATE USER new_user IDENTIFIED BY password;

GRANT ALL PRIVILEGES ON Employee TO new_user;

-- 2. Insert three records into the Employee table and rollback

BEGIN TRANSACTION;

INSERT INTO Employee (EMPNO, ENAME, JOB, MANAGER_NO, SAL, COMMISSION)

VALUES

(1, 'John Doe', 'Manager', NULL, 5000, 1000),

(2, 'Jane Smith', 'Developer', 1, 4000, 500),

(3, 'Alice Johnson', 'Analyst', 1, 3500, NULL);

ROLLBACK;

-- Check if any records were inserted

SELECT * FROM Employee;

-- 3. Add primary key constraint and not null constraint to the Employee table

ALTER TABLE Employee

ADD CONSTRAINT PK_Employee_EMPNO PRIMARY KEY (EMPNO);

ALTER TABLE Employee

MODIFY (ENAME VARCHAR2(50) NOT NULL,

JOB VARCHAR2(50) NOT NULL,

SAL NUMBER(10, 2) NOT NULL);

-- 4. Insert null values into the Employee table and verify the result

INSERT INTO Employee (EMPNO, ENAME, JOB, MANAGER_NO, SAL, COMMISSION)

VALUES (4, NULL, NULL, NULL, NULL, NULL);

-- Check if the record was inserted

SELECT * FROM Employee;

Make sure to replace `VARCHAR2` and `NUMBER` with appropriate data types based on your DBMS.

You might also like