Program 2 and 3
Program 2 and 3
Program 2 and 3
ACTIVATE/USING DATABASE
mysql> use COMPANY1173;
Database changed
DISPLAYING ALL THE TABLES:
mysql> show tables;
Empty set (0.00 sec)
TABLE 1: EMPLOYEE1173
TABLE CREATION
mysql> create table EMPLOYEE1173(fname varchar(10), minit varchar(3),
lname varchar(10), ssn integer(5), bdate date, address varchar(10), sex
varchar(1), salary integer(8), superssn integer(5), dno varchar(5));
Query OK, 0 rows affected, 3 warnings (0.02 sec)
mysql> desc employee1173;
INSERTION
mysql> insert into employee1173 values('MURALI',' ','RAJ',222,'1992-04-03',
'BANGALORE', 'M', 700000, 222,'D1');
Query OK, 1 row affected (0.00 sec)
INSERTION
mysql> insert into department1173 values('Research','D1','1001','2000-01-04');
Query OK, 1 row affected (0.00 sec)
TABLE 3: DEPT_LOC1173
TABLE CREATION
mysql> create table DEPT_LOC1173(dname varchar(10),dno varchar(5),
dlocation varchar(15));
Query OK, 0 rows affected (0.01 sec)
mysql> desc dept_loc1173;
INSERTION
mysql> insert into dept_loc1173 values('D1','BANGALORE');
Query OK, 1 row affected (0.00 sec)
TABLE 4: PROJECT1173
TABLE CREATION
mysql> create table PROJECT1173(pname varchar(10),pno
varchar(5),plocation varchar(10), dno varchar(5));
Query OK, 0 rows affected (0.01 sec)
mysql> desc PROJECT1173;
INSERTION
mysql> INSERT INTO PROJECT1173 VALUES ('WEBSITE', 'P1',
'BANGALORE', 'D4');
Query OK, 1 row affected (0.04 sec)
INSERTION
mysql> INSERT INTO WORKS_ON1173 VALUES (333,'P2',160);
Query OK, 1 row affected (0.00 sec)
TABLE 6: DEPENDENT1173
TABLE CREATION
mysql> create table DEPENDENT1173(essn varchar(10),dependent_name
varchar(20), sex varchar(1),bdate date, relationship varchar(10));
Query OK, 0 rows affected (0.02 sec)
mysql> DESC DEPENDENT1173;
INSERTION
mysql> INSERT INTO DEPENDENT1173 VALUES('333','RAJA','M','2017-
08-05','SON');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO DEPENDENT1173 VALUES ('555', 'ASHWINI', 'F',
'2000-07-25', 'DAUGHTER');
Query OK, 1 row affected (0.00 sec)
DISPLAY OF ALL THE RECORDS:
mysql> SELECT * FROM DEPENDENT1173;
UPDATION:
mysql> SELECT * FROM EMPLOYEE1173;
mysql> update employee1173 set sex='M' where ssn=777;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
DELETION OF RECORD
mysql> SELECT * FROM DEPENDENT1173;
mysql> delete from dependent1173 where essn=555;
Query OK, 1 row affected (0.00 sec)
ROLLBACK
mysql> rollback;
Query OK, 0 rows affected (0.00 sec)
COMMIT
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
PROGRAM – 3
Perform the following:
a. Altering a Table, Dropping/Truncating/Renaming Tables, Backing up /
Restoring a Database.
mysql> show databases;
mysql> COMMIT;
Query OK, 0 rows affected (0.00 sec)
ALTER – RENAME(TABLE NAME)
TRUNCATE
mysql> truncate table works_on1173;
Query OK, 0 rows affected (0.04 sec)
mysql> show tables;