SQL Server Create Table
Create Table
Table object in the
database are physical objects which holds the data in hard drive. Once created
will remain in database until unless you won’t drop it.
There are three Major parts of a create table statement:
Datatype à It’s datatype which we want to defined for the particular column.
For our example which we discussed in earlier chapters we will create the Customer, Product, Order and Order Detail.
As you read last
chapter Designing Data
Model for the Database for retail store data model we have finalized 4 tables for creating
database.
Now in this chapter
we will learn how to Create Alter or Drop table syntax with using the tables
from retail model example.There are three Major parts of a create table statement:
Create table
TableName (Column1 Datatype, Coulmn2 Datatype ….)
Create Table
TableName à This statement is the declaration statement in which it’s specified the
object which will get created will be the type of table.
Column Name à Column name which you want in table.Datatype à It’s datatype which we want to defined for the particular column.
For our example which we discussed in earlier chapters we will create the Customer, Product, Order and Order Detail.
Create table
customer ( CustomerID int, Customer Name
Varchar(100),Customer Address Varchar(500),Gender Char(10))
Create Table
Product (Product ID Int , Product Name varchar(100),Unit int , PricePerUnit
Money)
Create Table
Order(OrderID Int , OrderNo varchar(20),CustomerID Int)
You can define the other
constraints also on table that you will learn in coming chapter.
In this way you can
create table physically in the database which later can be populated with data.
No comments:
Post a Comment