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

1. Create a table employee with following Column, Constraints and Data

2. Write SQL command to add a new column state in above table and insert the state name (BR,MP,UP, JH,BR,UP)respectively.

in progress 0
Garima Singh 55 years 1 Answer 1350 views Newbie 0

Answer ( 1 )

  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

Leave an answer

Browse
Browse