In: Computer Science
Create a ‘Student’ table using SQL query. The table must have at least five attributes from your choice with different data types.
Answer:
We have to create a database in order to create table in MySQL.
Create database using following command in MySQL
create database databasename; ( Syntax )
for example: create database Student;
And use the created database using following command.
> use databasename; ( Syntax)
> use Student;
Create a table Student using following command.
> create table Student(Student_ID VARCHAR(20), Student_Name CHAR(20), Student_DOB DATE, Student_Age INT, CGPA FLOAT(10,2));
Insert values to the Student table using following command;
> insert into Student values(Student_ID, Student_Name, Student_DOB, Student_Age, CGPA);
Retrieve the Student table details using following command.
> select *from Student;
Finally i have created a table Student table using five different attributes with different datatypes.
Thank you. Please ask me if you have any doubt.