Creating Tables
原站著录信息
摘要
Introduction to Tables Tables are grids that store information in a database similar to the way an Excel worksheet stores information in a workbook. Access provides three ways to create a table for which there are icons in the Database Window. Double-click on…
Introduction to Tables
Tables are grids that store information in a database similar to the way an Excel worksheet stores information in a workbook. Access provides three ways to create a table for which there are icons in the Database Window. Double-click on the icons to create a table.
the Database Window
Create table in Design view will allow you to create the fields of the table. This is the most common way of creating a table and is explained in detail below.
Create table using wizard will step you through the creation of a table.
Create table by entering data will give you a blank datasheet with unlabelled columns that looks much like an Excel worksheet. Enter data into the cells and click the Save button. You will be prompted to add a primary key field. After the table is saved, the empty cells of the datasheet are trimmed. The fields are given generic names such as "Field1", "Field2", etc. To rename them with more descriptive titles that reflect the content of the fields, select Format|Rename Column from the menu bar or highlight the column, right-click on it with the mouse, and select Rename Column from the shortcut menu.
Create a Table in Design View
Design View will allow you to define the fields in the table before adding any data to the datasheet. The window is divided into two parts: a top pane for entering the field name, data type, and an option description of the field, and a bottom pane for specifying field properties.
Field Name - This is the name of the field and should represent the contents of the field such as "Name", "Address", "Final Grade", etc. The name can not exceed 64 characters in length and may include spaces.
Data Type is the type of value that will be entered into the fields.
Text - The default type, text type allows any combination of letters and numbers up to a maximum of 255 characters per field record.
Memo - A text type that stores up to 64,000 characters.
Number - Any number can be stored.
Date/Time - A date, time, or combination of both.
Currency - Monetary values that can be set up to automatically include a dollar sign ($) and correct decimal and comma positions.
AutoNumber - When a new record is created, Access will automatically assign a unique integer to the record in this field. From the General options, select Increment if the numbers should be assigned in order or random if any random number should be chosen. Since every record in a datasheet must include at least one field that distinguishes it from all others, this is a useful data type to use if the existing data will not produce such values.
Yes/No - Use this option for True/False, Yes/No, On/Off, or other values that must be only one of two.
Description (optional) - Enter a brief description of what the contents of the field are.
Field Properties - Select any pertinent properties for the field from the bottom pane.
Field Properties
Properties for each field are set from the bottom pane of the Design View window.
Field Size is used to set the number of characters needed in a text or number field. The default field size for the text type is 50 characters. If the records in the field will only have two or three characters, you can change the size of the field to save disk space or prevent entry errors by limiting the number of characters allowed. Likewise, if the field will require more than 50 characters, enter a number up to 255. The field size is set in exact characters for Text type, but options are give for numbers:
Byte - Positive integers between 1 and 255
Integer - Positive and negative integers between -32,768 and 32,768
Long Integer (default) - Larger positive and negative integers between -2 billion and 2 billion.
Single - Single-precision floating-point number
Double - Double-precision floating-point number
Decimal - Allows for Precision and Scale property control
Default Value - There may be cases where the value of a field will usually be the same for all records. In this case, a changeable default value can be set to prevent typing the same thing numerous times. Set the Default Value property.
Primary Key
Every record in a table must have a primary key that differentiates it from every other record in the table. In some cases, it is only necessary to designate an existing field as the primary key if you are certain that every record in the table will have a different value for that particular field. A social security number is an example of a record whose values will only appear once in a database table.
Designate the primary key field by right-clicking on the record and selection Primary Key from the shortcut menu or select Edit|Primary Key from the menu bar. The primary key field will be noted with a key image to the left. To remove a primary key, repeat one of these steps.
If none of the existing fields in the table will produce unique values for every record, a separate field must be added. Access will prompt you to create this type of field at the beginning of the table the first time you save the table and a primary key field has not been assigned. The field is named "ID" and the data type is "autonumber". Since this extra field serves no purpose to you as the user, the autonumber type automatically updates whenever a record is added so there is no extra work on your part. You may also choose to hide this column in the datasheet as explained on a later page in this tutorial.
Indexes
Creating indexes allows Access to query and sort records faster. To set an indexed field, select a field that is commonly searched and change the Indexed property to Yes (Duplicates OK) if multiple entries of the same data value are allowed or Yes (No Duplicates) to prevent duplicates.
全文与附件
提交申请后,可在会员中心查看原件和附件的查找进度。
