0% found this document useful (0 votes)
2 views

SQL_DAY1_ASSI2

The document contains a series of MySQL commands for managing a STUDENT table, including inserting records, creating the table, and performing various queries. It shows the insertion of multiple student records, a count of students by branch, and the deletion of records from the ETC branch. Additionally, it includes commands to rename, truncate, and drop the table after manipulating the data.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL_DAY1_ASSI2

The document contains a series of MySQL commands for managing a STUDENT table, including inserting records, creating the table, and performing various queries. It shows the insertion of multiple student records, a count of students by branch, and the deletion of records from the ETC branch. Additionally, it includes commands to rename, truncate, and drop the table after manipulating the data.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

mysql> INSERT INTO STUDENT VALUES('VIJAYA',150,'CSE','CHENNAI');

Query OK, 1 row affected (0.11 sec)

mysql> INSERT INTO STUDENT VALUES('SITA',202,'ETC','KOLKATA');


Query OK, 1 row affected (0.08 sec)
mysql> CREATE TABLE STUDENT (NAME VARCHAR(20),ROLLNO int,BRANCH VARCHAR(20),CITY
VARCHAR(20));
Query OK, 0 rows affected (0.54 sec)

mysql> INSERT INTO STUDENT VALUES('RAVI',300,'EEE','DELHI');


Query OK, 1 row affected (0.08 sec)

mysql> INSERT INTO STUDENT VALUES('BASU',165,'ETC','CHENNAI');


Query OK, 1 row affected (0.07 sec)

mysql> INSERT INTO STUDENT VALUES('RASMI',107,'ETC','RKL');


Query OK, 1 row affected (0.08 sec)

mysql> INSERT INTO STUDENT VALUES('KARAN',111,'CSE','CTC');


Query OK, 1 row affected (0.10 sec)

mysql> INSERT INTO STUDENT VALUES('REKHA',117,'BME','BBSR');


Query OK, 1 row affected (0.09 sec)

Q1)
mysql> SELECT BRANCH,COUNT(*) FROM STUDENT GROUP BY BRANCH;
+--------+----------+
| BRANCH | COUNT(*) |
+--------+----------+
| CSE | 2 |
| ETC | 3 |
| EEE | 1 |
| BME | 1 |
+--------+----------+
4 rows in set (0.08 sec)
Q2)
mysql>
mysql> SELECT NAME,BRANCH,COUNT(BRANCH) FROM STUDENT WHERE BRANCH LIKE 'E%' GROUP
BY NAME,BRANCH;
+-------+--------+---------------+
| NAME | BRANCH | COUNT(BRANCH) |
+-------+--------+---------------+
| SITA | ETC | 1 |
| RAVI | EEE | 1 |
| BASU | ETC | 1 |
| RASMI | ETC | 1 |
+-------+--------+---------------+
4 rows in set (0.00 sec)

Q2)
mysql> DELETE FROM STUDENT WHERE BRANCH='ETC';
Query OK, 3 rows affected (0.10 sec)

Q30
mysql> ALTER TABLE STUDENT RENAME STUDENTINFORMATION;
Query OK, 0 rows affected (0.47 sec)
Q4)
mysql> TRUNCATE TABLE STUDENTINFORMATION;
Query OK, 0 rows affected (1.37 sec)
Q5)
mysql> DROP TABLE STUDENTINFORMATION;
Query OK, 0 rows affected (0.41 sec)

You might also like