alternative
  • Home (current)
  • About
  • Tutorial
    Technologies
    C#
    Deep Learning
    Statistics for AIML
    Natural Language Processing
    Machine Learning
    SQL -Structured Query Language
    Python
    Ethical Hacking
    Placement Preparation
    Quantitative Aptitude
    View All Tutorial
  • Quiz
    C#
    SQL -Structured Query Language
    Quantitative Aptitude
    Java
    View All Quiz Course
  • Q & A
    C#
    Quantitative Aptitude
    Java
    View All Q & A course
  • Programs
  • Articles
    Identity And Access Management
    Artificial Intelligence & Machine Learning Project
    How to publish your local website on github pages with a custom domain name?
    How to download and install Xampp on Window Operating System ?
    How To Download And Install MySql Workbench
    How to install Pycharm ?
    How to install Python ?
    How to download and install Visual Studio IDE taking an example of C# (C Sharp)
    View All Post
  • Tools
    Program Compiler
    Sql Compiler
    Replace Multiple Text
    Meta Data From Multiple Url
  • Contact
  • User
    Login
    Register

SQL -Structured Query Language - SQL Table - Create Table Tutorial

To create a SQL table with no. of the column in an existing SQL database, then we can use a ' CREATE TABLE ' statement.

If we want to create a table, we should name the table and also named the column with any name.

And also we should define the column with datatype as required.

 

Syntax-

The basic syntax of CREATE TABLE statement is given below –

CREATE TABLE table_name

(

colname1 colname1_datatype ,

colname2 colname2_datatype ,

….

colnameN colnameN_datatype

);

Datatype always depends on the column name. If users want to store id in the table, then obviously we can use int datatype, for username we can use varchar.

 

For example-

If we want to create

Table – user_detail

Column

  • Id as an Integer - int and primary key
  • Name as a String - varchar(50)
  • Email as a String - varchar(50) and  Unique
  • Dob as a String - date

Then use the following syntax-

CREATE TABLE user_detail

(

    id int primary key,

    name varchar(50) not null,

    email varchar(50) unique,

    DOB date

);

Run Query

 

This command will create a user_detail table, refresh the database if it is not visible.


Show command

show tables;

In MySQL workbench to see all the tables in the database.


Desc Command

Desc command is used to check the description of the table by the table_name.

Syntax-

desc table_name;

 

For example-

desc user_detail;

SQL -Structured Query Language

SQL -Structured Query Language

  • Introduction
  • Overview
    • How To Download And Install MySql Workbench
    • SQL Syntax
  • SQL Database
    • Create Database
    • Drop Database
    • Use / Select Database
  • SQL Table
    • Create Table
    • Alter - Rename Table
    • Alter - Add Column
    • Alter - Modify Column
    • Alter - Rename Column
    • Alter - Drop Column
    • Copy Table
    • Drop Table
  • SQL Insert
    • Insert Record
  • Sql Update
    • Update Record
  • Sql Select
    • Select Record
    • Select - Count
    • Select - Average
    • Select - Sum
    • Select - Min Max
    • Select - Distinct
    • Select - Limit
    • Select - First
    • Select - Last
  • Sql Clause
    • Like Clause
    • And Operator
    • Or Operator
    • Between & Not Between Operator
    • As or Alias
    • In Clause
    • Group By Clause
    • Having Clause
  • Sql Order By
    • Ascending
    • Descending
    • Random
    • Ascending Descending Multiple Column
  • SQL Joins
    • Joins and its type
    • Inner Join
    • Left Join
    • Right Join
    • Full Join
    • Cross Join
  • SQL View
    • Create View
    • Update View
    • Delete View
  • SQL Delete
    • Delete Table
    • Truncate Table
  • Sql Key & Constraint
    • Primary Key
    • Foreign Key
    • Unique Key
    • Not Null Constraint
    • Check Constraint
    • Default Constraint
  • Normalization
    • Overview
    • 1 NF
    • 2 NF
    • 3 NF
    • Boyce Codd normal form ( BCNF )

About Fresherbell

Best learning portal that provides you great learning experience of various technologies with modern compilation tools and technique

Important Links

Don't hesitate to give us a call or send us a contact form message

Terms & Conditions
Privacy Policy
Contact Us

Social Media

© Untitled. All rights reserved. Demo Images: Unsplash. Design: HTML5 UP.

Toggle