Wednesday, 29 April 2015

Table Manipulation in MYSQL Ubuntu


1)
First we have to create database.

    mysql> CREATE DATABASE school;


school   ------------------>   Database

2)
And we have to switch to new database named school.

    mysql> use school
    Database changed



3)
Create a table in the database school.

mysql>  CREATE TABLE IF NOT EXISTS student (student_id int(5) NOT NULL AUTO_INCREMENT, student_name varchar(20) DEFAULT NULL, student_age int(2), PRIMARY KEY(student_id));



4)
If you want to show columns in the table named student, the screen shot is given bellow:



5)
Insert the data into the table named student, the screen shot is given bellow:


6)
After insert the data into the table student we can display the content of the table:


7)
If you want to delete a row from the table and show the content after deletion:

 

8)
 If you want to update a row from the table and show the content after the updation:


9)
If you want to drop the table then use drop command:


10)
Delete the database: