Create a table employee with following Column, Constraints and Data and Write SQL command to add a new column state in above table and insert the state name (BR,MP,UP, JH,BR,UP)respectively.
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answer ( 1 )
SQL> CREATE TABLE employee( Emp_no_PrimaryKey number(3) NOT NULL PRIMARY KEY, Emp_name varchar(20) DEFAULT NULL, Designation varchar(25) NOT NULL,Join_Date date NOT NULL, Join_Basic decimal(10,2) DEFAULT NULL);
Table created.
SQL> INSERT INTO employee VALUES(101, ‘Ramesh Kumar’, ‘Asstt. Programmer’, ’20-Jan-2014′, 25000.00);
1 row created.
SQL> INSERT INTO employee VALUES(102, ‘Md. Ali’, ‘Sr. Programmer’, ’15-Mar-2006′, 50000.00);
1 row created.
SQL> INSERT INTO employee VALUES(103, ‘Michel’, ‘Programmer’, ’20-Jan-2010′, 30000.00);
1 row created.
SQL> INSERT INTO employee VALUES(104, ‘Amit Kumar’, ‘System Analyst’, ’20-Jan-2010′, 35000.00);
1 row created.
SQL> INSERT INTO employee VALUES(105, ‘Arshad Ali’, ‘Network Administrator’, ’20-Jan-2010′, 45000.00);
1 row created.
SQL> INSERT INTO employee VALUES(106, ‘Deepak Kumar’, ‘Programmer’, ’20-Jan-2008′, 40000.00);
1 row created.
SQL> ALTER TABLE employee
2 ADD state varchar(20);
Table altered.
SQL> UPDATE employee
2 SET state=’BR’
3 WHERE Emp_no_PrimaryKey=’101′;
1 row updated.
SQL> UPDATE employee
2 SET state=’MP’
3 where Emp_no_PrimaryKey=’102′;
1 row updated.
SQL> UPDATE employee
2 SET state=’UP’
3 where Emp_no_PrimaryKey=’103′;
1 row updated.
SQL> UPDATE employee
2 SET state=’JH’
3 where Emp_no_PrimaryKey=’104′;
1 row updated.
SQL> UPDATE employee
2 SET state=’BR’
3 where Emp_no_PrimaryKey=’105′;
1 row updated.
SQL> UPDATE employee
2 SET state=’UP’
3 where Emp_no_PrimaryKey=’106′;
1 row updated.
Attachment