Dropping a Constraint
Dropping a Constraint
You can drop constraints from a table with Enterprise Manager. Although you do not have to disable a constraint before dropping it, you can determine whether the constraint can be dropped by attempting to disable it first. If a constraint in a parent table enforces a foreign key constraint in a child table, and if the child table contains dependent rows, then the constraint cannot always be disabled or dropped.
Continuing the current example, you drop the primary key constraint that you created in the section, "Creating a New Table Constraint" .
To drop a constraint:
1. On the Tables page, enter MYUSER in the Schema box and click Go. The result list should shows the PURCHASE_ORDERS table that you created
previously.
2. Select the PURCHASE_ORDERS table and click Edit. The Edit Table: MYUSER.PURCHASE_ORDERS page appears.
3. Click Constraints. The Constraints property page appears.
4. Select the row containing the PRIMARY constraint from the Constraints table and click Delete.
5. Click Apply.
A confirmation message appears.
Loading Data Into Tables
You can use Enterprise Manager to load data into tables in batch. Batch loading is useful when you have a lot of data. You can load data from the file system. You can also export data into files.
For loading data with Enterprise Manager, you can use a comma-delimited data file. Enterprise Manager can also create your control file automatically. This SQL*Loader control file tells Oracle how the data is to be loaded. It is different from a database control file.
The following example loads data into the purchase_orders table we created with MYUSER in "Creating a Table: Example" on page 8-9. For simplicity, this example loads only three rows. Your control and data files can be different, but the idea is the same for this method of loading.
This example requires you to create a data file named load4.dat on the file system of the database host or on your client host. The contents of the file should be as follows:
1, 25-MAY-2005, Office Equipment, Optical Mouse
2, 18-JUN-2005, Computer System, Dell Laptop
3, 26-JUN-2005, Travel Expense, Car Rental
Managing Schema Objects 8-13
To load the data file into the myuser.purchase_orders table:
1. From the Move Row Data section of the Maintenance page, click Load Data from User Files .
The Load Data: Generate Or Use Existing Control File page appears.
2. Select Automatically Generate Control File. Also enter the Host Credentials (username and password) for the host machine. Click Continue.
The Load Data: Data Files page appears.
3. Select Data File is Located on Database Server Machine and enter the path to your data file. Alternatively, if you created the data file on your client host, select Data File is Located on Your Browser Machine and enter the file path. Click Next.
The Load Data: Table and File Format page appears. This page displays the contents of your data file.
4. In Table Name, specify the destination table for your data. Enter myuser.purchase_orders and click Next.
The Load Data: File Format Attributes page appears.
5. Accept all defaults. In this example, we use the comma character as the delimiter. Click Next.
The Load Data: Load Method page appears.
6. Accept the default Conventional Path as the loading method. If you have a lot of data, you can select Direct Path. Click Next.
The Load Data: Options page appears.
7. In the Optional Files section, leave Generate log file where logging information is to be stored checked. You can accept the default file name and path or enter a different one. Note that this page gives you the option of limiting the number of rows loaded. Because we are only loading three rows in this example, we leave this box unchecked. Click Next.
The Load Data: Schedule page appears.
8. Enter values for Job Name and Description. Select Immediately to run the job now. Click Next.
The Load Data: Review page appears. This page lets you review your file names and loading methods. You can also view your loading control file. If you want to change something, you can click the Back button.
9. Click Submit Job to start the loading. The Job Activity page appears, confirming that your job was created successfully.
10. Search for your job name to view its status. The Job Activity page should display your job information and show that your job
succeeded. You can get more information by clicking the link under Status.
11. You can confirm the loaded data by navigating to the Tables page, searching for the myuser.purchase_orders table, and choosing View Data as the action. See Figure 8–6, "View Data: MYUSER.PURCHASE_ORDERS" .
8-14 Oracle Database 2 Day DBA
Figure 8–6 View Data: MYUSER.PURCHASE_ORDERS
See Also: "About Tables" on page 8-3 for more information.
Dropping a Table
If you no longer need a table or its contents, then you can drop the table using Enterprise Manager. Be certain that you really do not need the data in the table before you drop it. It may be difficult and time-consuming to retrieve the records, if they can
be retrieved, after you execute the drop statement. To test this procedure, follow the procedure in "Creating Tables" on page 8-8 to create a
table named test in the MYUSER schema. Create the test table with one column called col of type VARCHAR2(1).
To drop a table:
1. On the Tables page, enter MYUSER in the Schema box and click Go. The result list should show the test table that you just created.
2. Select the TEST table and click Delete With Options. The Delete With Options page appears.
3. Select Delete the table definition, all its data, and dependent objects (DROP).
4. Check Delete all referential integrity constraints (CASCADE CONTRAINTS).
5. Click Yes. The Edit table page displays a confirmation message when the table is successfully
deleted.
Managing Indexes
The following sections describe how to create and manage indexes:
About Indexes
Viewing Indexes
Managing Schema Objects 8-15
Creating Indexes
Dropping Indexes
About Indexes
Indexes are optional structures associated with tables. You can create them to improve query performance. Just as the index in this book helps you to quickly locate specific information, an Oracle index provides a quick access path to table data.
You can create indexes on one or more columns of a table. After an index is created, it is automatically maintained and used by Oracle. Changes to a table's data or structure, such as adding new rows, updating rows, or deleting rows, are automatically incorporated into all relevant indexes with complete transparency to the user.
Some indexes are created implicitly through constraints that are placed on a table. For example, a column with the constraint that its values be unique causes Oracle to create
a unique key index. When you click the Indexes link in the Database Objects section of the Administration
page, an Indexes page appears. This page is similar in content and functionality to the Tables page shown in Figure 8–3 .