Sql Tutorial Class


create table sql

Create table sql

Creating table in sql server using Sql Query


The table is very important in the SQL server database. The table plays a vital role in storing data in the database. It is a combination of row and columns means that the table has rows and columns. Without row and columns, the table cannot be created. The table has archived the name of the column called as CustomerName, CustomerAddress CustomerPhone, EmailAdd, etc. When the row and column intersect, there is only one place called a cell. The cell has as Name, Address, Telephone, etc.

Example
creating table in sql server sql query


Before Creating table in SQL Server using SQL Query. Users most know about the VARIABLES and DATATYPES.

1. Variables: when storing data on the computer. The computer must assign the memory location. The data can be changeable in the lifetime of the program. To locate the memory on the computer is called Variable.

2. Type of data: when the user saves the product name, it means that the name cannot be a number. It must be text. Like when the user saves the price of the product, there must be a number that cannot use text. As date, time, image, etc. For data identification must be declared before storing the data in the computer.

Some of DataTypes on Sql Server

Data type Description Max size
varchar(n) character string 8,000 characters
char(n) fixed character string 8,000 characters
int whole numbers  between -2,147,483,648 and 2,147,483,647
float(n) floating number  from -1.79E + 308 to 1.79E + 308.

For more DataType click here.

Now creating  simple table in Sql Server

Syntax: 
Create Table Table-Name
(
Column-Name/Field-Name DataType length,
Column-Name/Field-Name DataType length,
Column-Name/Field-Name DataType length,
Column-Name/Field-Name DataType length,
Column-Name/Field-Name DataType length,
Column-Name/Field-Name DataType length,
Column-Name/Field-Name DataType length
)

Example: 

Create Table ItemDetails
(
ItemCode int,
ItemName varchar(30),
ManufactureCompany varchar(50),
ExpiredDate date,
ItemSearialNo varchar (30),
ItemCategory varchar(30),
ItemQuantity int,
ItemPrice float,
ProductCountry varchar(30),
ReceivedDate date,
ItemImage image
)


[Note: varchar (30): It means 30 characters can store]


Creating table in SQL server






Creating table in sql server

creating table in sql server using sql query


Now, execute the sql statement
To Execute sql statement follow the steps
 > Select sql statement (See image in billow) > Click on Execute option / Press F5 key on keyword (See image in billow). Now you will see the successful message as image billow.

creating table in sql server using sql query




No comments:

Post a Comment