Create Table Command
SQL CREATE Command is used to
create a table or database in SQL. We use the same CREATE command in MySQL and
MSSQL Server.
Ø CREATE DATABASE
SYNTAX:
CREATE DATABASE
nameofdatabase;
EXAMPLE:
CREATE DATABASE
students;
DESCRIPTION:
CREATE Query can also be
used to create database. Just type CREATE DATABASE followed by the name of
database. Once a databse is created then we can use create query again to
create tables inside it.
Ø CREATE TABLE
CREATE TABLE
nameoftable(column1, column2, column3)
DESCRIPTION:
CREATE TABLE query is
used for creating tables. We need to specify the name of columns (in example
below itemid, itemname etc) and the datatypes(int, decimal). This example is
for MySQL.
EXAMPLE:
CREATE TABLE
ITEMS
(
ItemID INT PRIMARY KEY
AUTO_INCREMENT,ItemName VARCHAR(60),
ItemPrice DECIMAL(10, 2),
ItemCat VARCHAR(60),
ItemDesc TEXT
)
No comments:
Post a Comment