CREATE a database
To create a new database SQL syntax is
CREATE DATABASE my_newdb
'my_newdb' database will be created. The associated .MDF and .LDF files will be created under default path 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA' assuming SQL Server is installed under C drive
If you need to create database in a specified path example D:\MyName\MyDatabases
CREATE DATABASE [my_newdb] ON PRIMARY
( NAME = N'my_newdb', FILENAME = N'D:\MyName\MyDatabases\my_newdb.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB)
LOG ON
( NAME = N'my_newdb_log', FILENAME = N'D:\MyName\MyDatabases\my_newdb_log.ldf' ,SIZE = 13312KB , FILEGROWTH = 10%)
GO
GO
CREATE a table
To create a new table SQL syntax is
CREATE TABLE table_name
(
col_name1 datatype(size),
col_name1 datatype(size),
col_name1 datatype(size)
) ;
(
col_name1 datatype(size),
col_name1 datatype(size),
col_name1 datatype(size)
) ;
Example:
CREATE TABLE Employee
(
Emp_Id INT,
Emp_Name VARCHAR(50),
Emp_Address VARCHAR(200),
Emp_City VARCHAR(100),
Emp_Pincode INT
);
CREATE statement is used to create many other objects/constraints etc. as shown below(
Emp_Id INT,
Emp_Name VARCHAR(50),
Emp_Address VARCHAR(200),
Emp_City VARCHAR(100),
Emp_Pincode INT
);
CREATE VIEW
CREATE FUNCTION
CREATE PROCEDURE
CREATE INDEX
CREATE TRIGGER... etc
Almost for 50 types we can use CREATE clause. Please refer this link for more details
More details on CREATE statement
No comments:
Post a Comment