Lets
say I want to create an employee table with below fields
id
: Integer
firstName
: String
lastName
: Stirng
salary
: double
mailId
:String
Before
creating a table, create a database and tell MySQL use this database.
CREATE
DATABASE sample;
USE
sample;
Syntax
CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype, ..... columnN datatype, PRIMARY KEY( one or more columns ) );
Example
CREATE TABLE employee ( id int, firstName varchar(30), lastName varchar(30), salary decimal, mailId varchar(30), PRIMARY KEY(id) );
Above
statement creates employee table and makes id as a primary key for
employee table.
No comments:
Post a Comment