Read
SQL - Some Examples before proceeding..
==============================================
When we open SQL ( I am using SQL server-2005) , we can see a screen as
Here,
- Server name is the name we are giving at the time of SQL Installation.
- Authentication : 2 types of Authentications are there namely , (a) Windows Authentication and (b) SQL Server Authentication . Window Authentication doesn't require user name and password , hence a little secure. But on the other hand , SQL Server Authentication requires user name and password. Here sa is the default user name and password we can set.
Click Connect .
Then the home screen will open as ;
(A) How to create a Database ?
- You can see the option Databases.
- Right click on Database , then we can see a drop down menubelow it. , and click New Database.
- Then we can see a screen as ;
- Give the Data base name .Here I am giving Registraion , then click OK.
- Now we will return to the previous screen. Click on the + symbol to enlarge the options(or double click on it) and we can see some other options formed below it, with the database name Registration.
(B) How to create Tables ?
Now we creating
Tables for the database
Registration .
Double click the database
Registration or ( click on the + symbol to enlarge) , and some other options below it. Select
Table from that list ;
Now , as told before,right click on that Table , and select
New Table from the drop down menu , to create a new table .
Now we can see an option with
Column name &
Data type to create a table.
Suppose , we want to enter the registration details , with column names as
id, first name , last name , age , address and email id , we can set the fields like this .
As we enter the fields, we can see there is a number of
Data types also be there . Choose them as per the
column name .
Note that , below that , we can see the
column properties also.
Some fields like
ID of a person should not repeat , and we can thus set it as Primary Key. When we set a
primary key , that field will not repeat. That means , two persons cannot have
same ID.
How to set Primary Key ?
Select the field in which we want to set the primary key.
We can see an arrow there , and right click on that arrow .Then we can see a drop down menu , and from that drop down menu , select
Set Primary Key . Now we can see LOCK symbol , which implies, "that id is set to as primary key and will never repeat for another field ".
See the figure below :
Hope you understand , how to create a Database and Table.
Back to SQL .
NEXT CHAPTER
PREVIOUS CHAPTER