Powered By Blogger

Friday, July 29, 2011

How To Create Table in Ms Access 2007

How to create table in Ms Access:

1. Click on start menu than choose Microsoft Office open ms access.
2. Add new database or create new database two ways we have to do this



Here in above pic click at new and choose new database

3. After clicking new or blank database from one of above option this following page will displayed here we have to set Database name
Here I am setting database name MyDb.




After clicking button create on right bottom side of highlited area our blank data base will be created 


After clicking it will display on and on right side there is default table of database
On left side at Table 1 right click there and choose design mode option than following option will display



At this step we have to save table name as displaying above .

As in following image I set table name tbemp (table for employee details) . in following pic u can see on left side where now table name is changed to tbemp:Table from Table1:table
And on the right side u can see there are 2 fields – field name and Datatype
Field name :
Field name is specified as name of columns of the table eg. empId , empName , empAdd, EmpSal

DataType:
DataType is must to use any field in table when we create or declare a field in table we must add its datatype with field name
Example

FieldName Datatye
empId AutoNumber
empName Text
empAdd Text
empSal Number

As in above table I have four fields with their datatypes
I use Auto number for empId – because empId is unique column of table whose value cannot be repeat because in every table we need a column who is unique because to retrieve records . it can better explain with an example
Select empname, empadd, empsal from tbemp where empId =1

I use in above example empid with where condition because emp id Is unique and consist primary key and it have datatype of autonumber. When we insert records in table we will insert values in all columns but not in empid because everytime it will fill automatically like 1,2,3,4,5 and so on
And for fetching records from table we only use column with unique and primarykey . Because primary key we cannot repeat any value of column and in case of other columns they can b repeat like “name = navi”. Name navi can have one or more people but its id must relates to only one person like in ur case ur roll number is ur primary and unique column.

In our example :

As u can see in following image I choose above fields and datatypes.

DataType:
Datatype Is related to every column or field name of table. It is use to tell ur column’s type like : empName- Text (in empname we can enter value like text like amit ) and empSal – Number (its value like 25000)



After creating table next step is to enter data in table as in following pic u can see
I have to enter just name, address and salary in table id will generate automatically

No comments:

Post a Comment