Hello,
Syntax for use-
(101, Ram, M, 24) is a row of student table also known as tuples or record
query to create a tabale-
In the previous tutorial we just know about some basic concept about MySQL and some basic SQL commands.
In this tutorial I will tell you about some new SQL (Structured Query Language) statements.
USE statement
This command is used for changing or selecting the database from a list of databases.
when we use show databases; statement, it list all available databases for a user.
so for selecting a particular database for working we use USE statement.
Syntax for use-
mysql> use db; // replace db to your database name
As we know RDBMS uses table to represent data. so in RDBMS database contain a collection of tables.
Table is like a matrix contains rows and columns.
rows also knows a tuple or record
Here is an example of how a tables look like in MySQL.
![]() |
student table |
you can see an example of table named student where roll_no, name, sex, age are column name.
(101, Ram, M, 24) is a row of student table also known as tuples or record
CREATE statement in MySQL
Create a database
In this section we learn about how to create a database in MySQL.
To create a database in MySQL we uses CREATE statement-
Suppose we are going to crate a database name college which store the student details.
mysql > CREATE DATABASE college;
It will create a college database in your MySQL server. you can check it using SHOW DATABASES; statement.
Create a table in database
In this section we learn about how to create a table in MySQL.
To create a table in MySQL we uses CREATE statement-
Step 1- First select the database (USE statement) in which you want to create a database.
In our case we use college as database that we just created.
USE college;
Step 2- Now we create a table student-query to create a tabale-
mysql> CREATE TABLE student(roll_no varchar(20), name varchar(20), sex char(1), age int(3));
this command will create a table called student, which roll_no, name, sex, age as column name
DESC statement
DESC statement is used to show the structure of a table.
Query to see the structure of table-
mysql> DESC student;;
![]() |
student table structure |
No comments:
Post a Comment