CCNC/CCNC Module 5/Designing and creating tables/Basic Table Operations/Edit A Table
|Basic Table Operations|
Editing a table design
Editing a Table
Once you have created a table you may find that you wish to add another field at a later stage. This you do by right-clicking on the table name and choosing Edit. If you want the field at the end then simply click in the row underneath the last field and enter the new field. Click on the Save button to save the change. If you forget to save the table you will prompted to do so when you close it.
If you want the new field to appear within the current fields, ie not at the end, then click on the grey button to the left of the field that you want to be after the new field and right click. A pop up menu will appear allowing you to choose to insert rows. Click on Insert Rows and you have a new row in which to enter your field.
As with many tasks within OpenOffice Base there are many ways to do the same task. When editing an existing table to change its design you could choose any of the following methods;
A table can be opened for editing by highlighting the table to edit and using the Edit menu and select Edit...
You can also open a table for editing by highlighting the table and selecting the Edit button from the toolbar. (Figure 2.)
Remember: to turn on the table toolbar select the View menu and then Toolbars and Table.
Another method is to right-click on the table for editing and select Edit from the pop-up menu.
Making changes to an existing table can be a challenge for a table may already contain data or the table may have foreign key dependencies. Making changes can violate the tables existing data integrity rules. If the changes to be made do violate these existing rules this will often mean that the table will have to be changed in a multi-step process with accompanying data management tasks.
Open an existing table (that already contains data) so it can be Edited. Add another field to the table design and set the 'Entry Required' property to 'Yes'. In our example we have opened the 'People' table and added a 'nationality' field. Once the changes have been made, save the table.
An error message is presented to us for we have violated the 'Entry Required' rule. When the database tried to save the table it attempted to apply all the rules to the data in the table. The 'Entry Required' rule on the 'nationality' field (or column) would have been in violation for their is NO data in this new field.
- Column is another name for a field or attribute. The difference being is column is referred to when the table is open for adding or viewing the data. Its like the column of a spreadsheet.
To fix this problem we open the table is design mode and change the 'Entry Required' property on the 'nationality' field to 'No'. We save the table and this time we get no error for their is no rule being violated.
Adding data to the new column
We then add data values to ALL the fields in the new 'nationality' column. Close the table.
We re-open the table in design and then set the 'Entry Required' property to 'Yes'. When we again save the table with this new rule we do not get an error for the 'nationality' column contains data.
Test your knowledge