Chitika

Friday, October 19, 2012

Data base and table creation in sql server


In my previous article i have given introduction to sql server data types now its time for creating database and table.
Database:

SQL Server manages the objects in a container known as Database, where we can have multiple databases present in it, each database when created creates 2 files internally those or .mdf and .ldf file.

Syntax for creating a database:
            -CREATE DATABASE <db_name>
           
-Database names must be unique within an instance of SQL Server.
-Any Object name in sqlserver can be of 1 through 128 characters

Tables:

-It is the object, which will store the information in the database in the form of rows and columns.

Syntax for creating a Table:
            -CREATE TABLE <table_name>(
             column_name1 <dtype> [width],
             column_name1 <dtype> [width],
             ………………….
             column_namen <dtype> [width])

-Table names must be unique within the database.
-Column names must be unique within the table.
-Every table can have maximum of 1024 and minimum of 1 column.

            -CREATE TABLE Bank(Custid int, Cname varchar(50), Bal decimal(7,2))
In the next article i will explain about commands in sql server.

No comments:

Post a Comment