Database:
Database is a collection of information which used to store in a table format.
Each database can contain more than one table.
We can easily access the data and we can perform operations on data like Create,select,update and delete the data.
Ex:1 To create a new database using command
Syntax:
Create database [ database name];
Ex: create database employeeinformationdb;
Ex:3 To Delete the table by using management studio:
Step 1: Right click on the database which you want to delete.
Step 2:Click ok button to proceed
Step 3: After refreshing the database
Ex:4 To Drop the table by using drop command:
Syntax:
Database is a collection of information which used to store in a table format.
Each database can contain more than one table.
We can easily access the data and we can perform operations on data like Create,select,update and delete the data.
Ex:1 To create a new database using command
Syntax:
Create database [ database name];
Ex: create database employeeinformationdb;
- Create is a sql command which is used to create a new database,table etc..
After refreshing the databases then we can see the newly created database.
Ex:2 Creating database by using management studio:
Step 1: Right click on database
Step 2: Double Click on the new database and type the name of the new database.
After refreshing the database then you can see the newly created database.
Ex:3 To Delete the table by using management studio:
Step 1: Right click on the database which you want to delete.
Step 2:Click ok button to proceed
Step 3: After refreshing the database
Ex:4 To Drop the table by using drop command:
Syntax:
Drop database [ database name];
Ex:drop database employeeinformationdb;
Sql Data Types:
SQL data types define the type of value that can be stored in a table column.
We have different data types.
1.Numerical data types.
Data type Storage
Bit 1,0,Null
Tiny int 1 byte(0 to 255)
Small int 2 bytes(-32768 to 32767).
Int 4 bytes(-2,147,483,648 to 2,147,483,647 ).
Bigint 8 bytes.
Real 4 bytes
Smallmoney 4 bytes
Money 8 bytes
Float 8 bytes
Decimal(p,s): The precision is the n umber of digits in a number and scale is the number of digits to the right of the decimal.
Ex: 125.45 is a number. Precision value is 5 and scale is 2.
Numeric(p,s): It is same as decimal but the only difference is it specify exact precision and scale value.
2.String Data types
Char: It's length is Fixed.1byte(Max lentgth is 8000).It is non unicode.
varchar: It's length is not fixed.1byte.used to store non unicode data.
Nchar: It's length is fixed.2bytes storage.It stores unicode data.
Nvarchar: It's length is not fixed.Storage is 2bytes.It stores unicode data.
Text: It's length is fixed.It stores non unicode data.Maximum size is 2GB of data.
Ntext: It's length is Not fiexd.It stores non code data.Maximum size is 1GB.
Binary: It's length is fixed. Maxlength is 8000 bytes.
Vbinary: It's length is not fixed. Maxlength is 8000 bytes.
Image: Variable length storage with maximum of 2GB binary data.
3.Date:
Date: It gives only date. It stores only 3 bytes.
Time: It gives only time. it stores 3-5 bytes.
Datetime: It returns date and time. It stores 8 bytes.
4.Xml
Xml: It stores xml formatted data.It's maximum size is 2GB.
Sql Data Types:
SQL data types define the type of value that can be stored in a table column.
We have different data types.
1.Numerical data types.
Data type Storage
Bit 1,0,Null
Tiny int 1 byte(0 to 255)
Small int 2 bytes(-32768 to 32767).
Int 4 bytes(-2,147,483,648 to 2,147,483,647 ).
Bigint 8 bytes.
Real 4 bytes
Smallmoney 4 bytes
Money 8 bytes
Float 8 bytes
Decimal(p,s): The precision is the n umber of digits in a number and scale is the number of digits to the right of the decimal.
Ex: 125.45 is a number. Precision value is 5 and scale is 2.
Numeric(p,s): It is same as decimal but the only difference is it specify exact precision and scale value.
2.String Data types
Char: It's length is Fixed.1byte(Max lentgth is 8000).It is non unicode.
varchar: It's length is not fixed.1byte.used to store non unicode data.
Nchar: It's length is fixed.2bytes storage.It stores unicode data.
Nvarchar: It's length is not fixed.Storage is 2bytes.It stores unicode data.
Text: It's length is fixed.It stores non unicode data.Maximum size is 2GB of data.
Ntext: It's length is Not fiexd.It stores non code data.Maximum size is 1GB.
Binary: It's length is fixed. Maxlength is 8000 bytes.
Vbinary: It's length is not fixed. Maxlength is 8000 bytes.
Image: Variable length storage with maximum of 2GB binary data.
3.Date:
Date: It gives only date. It stores only 3 bytes.
Time: It gives only time. it stores 3-5 bytes.
Datetime: It returns date and time. It stores 8 bytes.
4.Xml
Xml: It stores xml formatted data.It's maximum size is 2GB.