Creating Tables - MySQL


Creation of Database




A database is a systematic collection of interrelated data stored together in the form of multiple tables with rows and columns so that it can be easily accessed and managed.

The 'CREATE DATABASE' statement is used to create a new SQL database.

CREATE DATABASE databasename;
                

CREATE DATABASE myfirstdatabase;
        
                        

Show Database




SHOW DATABASES lists the databases on the MySQL server host.
 
SHOW DATABASES;

Use Database




The USE statement of MySQL helps you to select/use a database
 
USE myfirstdatabase;

Creation Of Tables




A table is a logically organised format of rows and columns, each row represent a unique record and each column represent a field in the record.

Tables are created with 'create table' command. Each table must have at least one column

CREATE TABLE table_name (
    column1 datatype,
    column2 datatype,
    column3 datatype,
    ....
);
            

Create a table named Student table with columns as StudentNo,Class,Name,Game,
Grades,SUPW,Grade2.
create table Student
( StudentNo int not null,
Class int not null,
Name varchar(20) not null,
Game varchar(30) not null,
Grades varchar(1) not null,
SUPW varchar(30) not null,
Grade2 varchar(1) not null
);

Create a table named ClubMembers with columns as Coach_id, Coach_name, Age
 
create table ClubMembers ( Coach_id int not null, Coach_name varchar(20) not null, Age int not null, );

Create a table named Customer with columns as CustomerID, Name, Location
 
create table Customer ( CustomerID int not null, Name varchar(20) not null, Location varchar(20) not null );

Create a table named Sales with columns as SalesID, CustomerID, Amount
 
create table Sales ( SalesID int not null, CustomerID int not null, Amount decimal(9,1) not null );

Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com