Skip Headers
Oracle® HTML DB User's Guide
Release 1.6

Part Number B14303-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

5 Managing Database Objects with SQL Workshop

This section provides information on how to use SQL Workshop to view and manage database objects, create and manage user interface defaults, and browse the data dictionary.

This section contains the following topics:

See Also:

About SQL Workshop

You can use SQL Workshop to view and manage database objects from a Web browser.

To access the SQL Workshop home page, click the SQL Workshop icon on the Workspace home page. (See Figure 5-1.)

The SQL Workshop home page is divided into four primary sections:

About Transaction Support

Oracle HTML DB is a browser-based development environment which communicates over HTTP. Because HTTP is a stateless protocol, any command you issue using SQL Workshop is automatically followed by a database COMMIT. There is no support for transactions that span multiple pages in the SQL Workshop. For example, you cannot issue an UPDATE statement on one page in the SQL Workshop and then revert it on a subsequent page using a ROLLBACK command.

Since the commands COMMIT, ROLLBACK and SAVEPOINT are executed as one transaction, you can include these commands in SQL Workshop by using scripts.

See Also:

"Using the SQL Script Repository" for information on running scripts

About Unsupported SQL*Plus Commands

SQL Workshop does not support SQL*Plus commands. If you attempt to enter a SQL*Plus command in SQL Workshop an error message displays. The following are examples of unsupported SQL*Plus commands:

SET ECHO OFF
SET ECHO ON
SET VERIFY ON
SET LONG 600
COLUMN dummy NOPRINT
COLUMN name FORMAT A20
DEFINE
ACCEPT
PROMPT
REMARK
SHOW

Viewing Database Objects

You can use SQL Workshop to view database objects. For example, you can view details about database objects by querying the Oracle dictionary. You can also run SQL commands and SQL scripts in the SQL Command Processor or view database objects in the Database Browser.

Topics in this section include:

Using the SQL Command Processor

You use the SQL Command Processor to run SQL commands and SQL scripts on any Oracle database schema for which you have privileges.

To access the SQL Command Processor:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, click SQL Command Processor.

    The SQL Command Processor appears.

  3. Select a schema from the list and follow the on-screen instructions.

  4. To run entered commands, click Run SQL.

    For example, to describe a database object you would type DESC MY_OBJECT. For example:

    DESC DEMO_ABOUT
    
    

    Alternatively, if you are using Internet Explorer, you can also press CTRL+Enter to execute your SQL Statement.

  5. To save entered commands, click Save.

See Also:

"Accessing Saved Commands in the SQL Archive" for more information on viewing saved commands and queries

About Command Termination

You can terminate commands in the Command Processor using either a semicolon (;) or forward slash (/). Consider the following examples:

INSERT INTO emp
      (50,'John Doe','Developer',10,SYSDATE,1000,10);

INSERT INTO emp
      (50,'John Doe','Developer',10,SYSDATE,1000,10)
/

The first example demonstrates the use of a semicolon (;). The second example demonstrates the use of forward slash (/).

Using Explain Plan

Use Explain Plan to view the plan the Oracle Optimizer uses to run your SQL Command.

To view the Explain Plan:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list on right side of the page, select Explain Plan.

    Explain Plan appears.

  3. Enter a command in the field provided and click Explain Plan.

Viewing Database Objects

You can use the Database Browser to view database objects. To find a database object, select the schema you would like to view. The values available in the schema depend upon your resource privileges.

To browse database objects:

  1. Click SQL Workshop on the Workspace home page.

  2. Under Database Browser, select the type of database object you would like to view.

  3. To search for an object, select a schema, an object type, type a search string in the Search field, and click Go. Searches are case insensitive and no wildcards or quotes are necessary.

  4. To view object details, click the View icon adjacent to the appropriate name.

  5. Optionally, select a task from the Tasks list on the right side of the page.

Querying by Example

Once you have located a specific table you can declaratively create a report to display the data in the table.

To Query by Example:

  1. Click SQL Workshop on the Workspace home page.

  2. Under Database Browser, select Tables.

    The Database Browser appears.

  3. Click the View icon to view details about a specific object.

    The Object Detail appears.

  4. From the Tasks list, select Query by Example.

  5. Follow the on-screen instructions.

Managing Database Objects

You can use SQL Workshop to manage database objects. For example, you can create new database objects, manage script files and control files, or alter a table.

Topics in this section include:

Creating Database Objects

You can create new database objects using the Create Database Object Wizard.

To create new database objects in SQL Workshop:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, select Create Object.

    The Create Database Object Wizard appears.

  3. Select the type of database object you would like to create.

  4. Follow the on-screen instructions.

Dropping Database Objects

You can drop database objects using the Drop Database Object Wizard. When you drop a table using this wizard, you also remove all related triggers and indexes.

To drop a database object:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list on the right side of the page, select Drop Database Object.

    The Drop Database Object Wizard appears.

  3. Select a schema and then an object type.

  4. Follow the on-screen instructions.

Restoring Dropped Database Objects

If you are running Oracle HTML DB with Oracle Database 10g release 1 (10.1), you can use the Recycle Bin to view and restore dropped database objects. When you drop a table, the space associated with the table is not immediately removed. The Oracle database renames the table and places it and any associated objects in the Recycle Bin where it can be recovered at a later time.

Note:

The Recycle Bin feature is only available if you are running Oracle HTML DB with an Oracle 10g database.

To use the Recycle Bin:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list on the right side of the page, select Manage Recycle Bin.

    The Recycle Bin appears.

  3. To search for an object, select a schema, an object type, type a search string in the Search field, and click Go.

  4. To view object details, click the View icon adjacent to the appropriate name.

    On the Object Summary page, you can:

    • Click Restore Object to restore the current object

    • Click Purge to permanently delete the current object

To empty the Recycle Bin without viewing the objects:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list on the right side of the page, select Manage Recycle Bin.

    The Recycle Bin appears.

  3. From the Tasks list on the right side of the page, select Purge Recycle Bin.

Using the SQL Script Repository

You can use the SQL Script Repository to view, edit, and run uploaded script files. For example, you can upload new script files as well as create and edit your create table, create index, and create PL/SQL package scripts.

Topics in this section include:

Managing Script Files in the SQL Script Repository

Use the SQL Script Repository to view, edit, run, and delete uploaded script files.

To view scripts in the SQL Script Repository:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Scripts, click Scripts.

    SQL Script Repository appears. Scripts are stored based on your workspace username.

  3. To search for a script, select a username from the Show list, enter a search string in the Find field (optional), and click Go.

    While in the Script Repository you can:

    • Reorder a list by clicking the column heading

    • View details about a specific file by clicking the View icon

    • Edit a script by clicking the Edit icon

    • Run a script by clicking Run in the Actions column

    • Delete a script by selecting it and clicking Delete Checked

    • Upload a script by clicking Upload

    • Create a script by clicking Create

To view script details:

  1. In the Script Repository, click the View icon.

    The Files Details page appears.

  2. Under View Links, you can:

    • Click Native file format to download the file locally

    • Click View document as text to view the file in your Web Browser

    • Click Parse this script to parse the script to run

To run a script in the Script Repository:

  1. In the Actions column, click Run.

    The Run page appears.

    If you have parameters in your script you must define them. You can define up to ten different parameters in each script.

  2. Enter a parameter name and value in the fields provided.

  3. To view the script file, click View File.

  4. To run the script file, click Run Script.

    The Run Results page appears displaying the number of success, failure and the elapsed time. RED indicates that errors occurred while executing the file.

  5. To view the script file source, click View Source.

  6. To run the file again, click Run Script again.

    Once you have run a script file, you can view a history of previous executions by clicking Previous Runs.

To delete a script file from the Script Repository:

  1. In the Script Repository, select the script to be deleted.

  2. Click Delete Checked.

Uploading and Creating Script Files

To upload a script file into the Script Repository:

  1. In the Script Repository, click Upload.

    The Upload Script page appears.

  2. Follow the on-screen instructions.

If the script file you upload has a valid file extension, SQL Workshop recognizes the file as a script and automatically parses it. Table 5-1 describes the file extensions SQL Workshop considers to be valid for script files.

Table 5-1 Valid Script File Extensions

Extension Description
pkh Package headers
plb Package bodies
sql Scripts
con Constraints
ind Indexes
sqs Sequences
tab Tables
trg Triggers
pkb Package bodes
pks Package specs

To create a script file while in the Script Repository:

  1. In the Script Repository, click Create.

    The Create Script page appears.

  2. Follow the on-screen instructions.

About Script Termination

You terminate a statement in a script by adding a carriage return and a forward slash (/) at the end of each statement. Consider the following examples:

INSERT INTO emp values(10,'aaa')
/
INSERT INTO emp values(20,'bbb')
/
INSERT INTO emp  values(30,'ccc')
/

Using Parameters in a Script

You can parameterize a script using a pound sign (#) or ampersand (&). The following two examples demonstrate valid parameter syntax.

CREATE TABLE #OWNER#.xyz (X INT)
/
CREATE TABLE #OWNER#.abc (Y NUMBER)
/

CREATE TABLE &OWNER.xyz (X INT)
/
CREATE TABLE &OWNER.abc (Y NUMBER)
/

Including SQL Queries in a Script

If you include SELECT statements in a script, the script will run without errors, but the result set will not display.

Exporting a Script File

You can export SQL Script Repository scripts using the Export Import Wizard in Application Builder.

To export a script from SQL Workshop:

  1. Navigate to the Workspace home page.

  2. Click Application Builder.

  3. When Application Builder appears, click Export/Import.

    The Export Import Wizard appears.

  4. Select Export and click Next.

  5. Click the Script Files button and follow the on-screen instructions.

If you export a UNIX format, the wizard generates a file with rows delimited by CHR (10) (that is, line feeds). If you export a DOS format then each row is terminated with CHR(13)||CHR(10) (that is, CR LF or carriage return line feed).

Accessing Saved Commands in the SQL Archive

When you click Save in SQL Command Processor, SQL Workshop saves entered commands and scripts to the SQL Archives.

The SQL Archives is different from the SQL Script Repository. By saving frequently used SQL commands in the SQL Archives, you can run the commands again without retyping. When you save a SQL command to the SQL Archives, the saved command does not appear in the Script Repository.

To view the SQL Archives:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list on the right side of the page, select Manage SQL Archive.

    SQL Archives appears. Scripts are stored based on your workspace username.

  3. Follow the on-screen instructions.

Accessing the SQL Command History

SQL Command History displays the 200 most recent commands and scripts run in the SQL Command Processor.

To view the SQL Command History:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list on the right side of the page, select View SQL History.

    SQL Command History appears.

  3. To run a command, click the appropriate SQL link.

    The selected SQL command or the script displays in the SQL Command Processor.

Generating DDL

If you are running Oracle HTML DB with Oracle Database 10g release 1 (10.1), you can use DDL statements to create, alter, and drop schema objects when they are no longer needed. You can also use DDL statements to grant and revoke privileges and roles, analyze table, index, or cluster information, establish auditing options, or add comments to the data dictionary.

To generate DDL statement in SQL Workshop:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Scripts, click Generate DDL.

    The Generate DDL Wizard appears.

  3. Follow the on-screen instructions.

See Also:

Managing Control Files

Control files enable you to run a series of scripts in a predefined order. From the Control Files Repository, you can create, edit, delete, or run control files.

To access the Control Files Repository:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Scripts, click Script Control.

    Control Files Repository appears.

  3. To search for a script, select a username from the Show list, enter a search string in the Find field (optional), and click Go.

    While in the Control Files Repository you can:

    • Reorder a list by clicking the column heading

    • Edit a file by clicking the Edit icon

    • Run a file by clicking Run

    • Delete a script by selecting it and clicking Delete Checked

To create a control file:

  1. In the Control Files Repository, click Create.

    The Control File Create page appears.

  2. Enter a name for the control file, select the script files you would like to include, and click Create.

  3. Specify the execution order and click Done.

To edit a control file:

  1. In the Control Files Repository, click the Edit icon.

    The Edit Control File page appears.

  2. On the Edit Control File page you can:

    • Change the order in which files are executed by clicking Edit Execution Order

    • Add additional script files by clicking Add More Files

    • Delete a script by selecting it and clicking Delete Checked

To run a control file in the Control Files Repository:

  1. In the Action Column, click Run.

    The Run File page appears.

  2. Select an Oracle Schema from the Parse As list.

    If your script files include parameters you must define them. You can define up to ten different parameters in each script.

  3. Enter a parameter name and value in the fields provided.

    If you wish to run the control file in the background, select Run in Background. Running a control file in the background means that Oracle HTML DB submits it as a job. The advantage of this approach is that you do not have to wait for it to finish to continue using SQL Workshop.

  4. Click Run File.

    The Run Results page appears displaying the number of success, failures, and the elapsed time. RED indicates that errors occurred while executing the file.

  5. To run the file again, select Run File again

Viewing the Control File Run History

Once you have run a file, you can view a history of previous executions by clicking Previous Runs on the Run File page.

To view the Control File Run History:

  1. Run the control file as described in the previous procedure.

  2. Select Previous Runs.

Viewing Control File Job Status

You can view control file job status from either the Edit File or Run File page.

To view the status of a job:

  1. Run the control file as described in the previous section with the Run in Background option selected.

  2. From the Tasks list, select View Job Status.

Managing Tables

You can also use SQL Workshop to create new tables or edit existing tables.

To create a new table:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, click Create Object.

    The Create Database Object Wizard appears.

  3. Select Table and click Next.

  4. Follow the on-screen instructions.

Note:

To edit an existing table, you must first navigate to it using the Database Browser.

To edit an existing table:

  1. Click SQL Workshop on the Workspace home page.

  2. Under Database Browser, select Tables.

  3. To search for a table, select a schema, table type, type a search string in the Search field, and click Go.

  4. To view table details, click the View icon.

    The Table Definition appears.

  5. To edit the table or generate a report, make selection from the Tasks list. Table 5-2 describes the options available on the Tasks list.

    Table 5-2 Table Tasks

    Task Description
    Count Rows Counts all rows in the currently selected table.
    Create Lookup Table Creates a lookup table for the column you select. The selected column becomes a foreign key for the lookup table.
    Drop this object Drops the current table.
    Generate Create Table Script Generates a create table script.
    Insert Row Inserts a row into the current table.
    Manage Table Displays a wizard for performing a variety of tasks on the current table, including:
    • table (copy, drop, rename, analyze, truncate)

    • columns (add, drop, modify, and rename)

    • constraints (add, disable, drop)

    • trigger (create, disable, drop, enable)

    • index (create and drop

    Popup Table Columns Displays a popup window that lists the columns in the current table.
    Query by Example Displays a form so you can create a report and view the data in selected columns.
    Report Dependent Objects Displays a report that describes database objects that have dependencies on the selected table.
    View Data Model Displays a report that shows the referential integrity constraints for the current table.

  6. To view user interface defaults, click the Manage User Interface Defaults button.

Managing User Interface Defaults

User interface defaults enable developers to assign default user interface properties to a table, column, or view within a specified schema. When a developer creates a form or report using a wizard, the wizard uses this information to create default values for region and item properties.

Since user interface defaults are associated with a table, you can use them with applications created using the form and report wizards.

Topics in this section include:

See Also:

"Application Builder Concepts" and "Using Application Builder" for more information on regions and item properties

Viewing Tables Utilizing User Interface Defaults

To view tables that utilize user interface defaults:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, select User Interface Defaults.

    A list of tables for which user interface defaults are defined displays.

  3. Select a specific table by clicking the Edit icon adjacent to the table name.

Editing a Column Attributes

You define user interface defaults for a specific column by editing column attributes on the Column Definition page.

To edit column attributes:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, select User Interface Defaults.

    A list of tables for which user interface defaults are defined displays.

  3. Select a specific table by clicking the Edit icon adjacent to the table name.

    The View Details page appears. The following information displays at the top of the page:

    • Schema is the schema that owns the table.

    • Table/View Name is the name of the selected table or view.

    • Report Region Title and Form Region Title becomes the default title for all report or form regions. Both of these names a modified versions of Table/View Name in which the first letter is capitalized and any underscores are replaced with spaces.

    Column-level User Interface Defaults appear next. You can edit select attributes for all displayed columns, by clicking Grid Edit.

  4. To select a specific column, click the Edit icon adjacent to the column name.

Editing Column-level Defaults

Edit Column-level Defaults is divided into two pages: Column Definition and List of Values. The topics that follow describes how to edit specific attributes on the Column Definition and List of Values pages.

Edit Column-level User Interface Defaults

The top of the page displays the selected schema, table or view name, and column name.

Default for Label (used in Reports and Forms)

Use Label to specify default label text for items in a form and the heading for columns in reports.

Defaults for Reports

Available Display for Reports attributes include:

  • Display - Indicates whether the column displays in a report. The default is Yes.

  • Display Sequence - Specifies the display sequence of items in a report. The default value is based on the column ID, which is based on the order of the columns in the table.

  • Display As - Specifies how the column should be displayed in reports

  • Mask - Indicates if a mask should be applied against the data. This attribute is not applicable for character- based items.

  • Alignment - Specifies report alignment (Left, Center, or Right). If the column is a number, the default is Right. Otherwise, the default is Left.

  • Searchable - Indicates whether the column should be searchable in reports. If the column is VARCHAR2 or CHAR, the default is Yes. If not, the default is No.

  • Group By - Indicates whether the column should be used for Group By and then the sequence of the grouping. The default is Yes.

  • Aggregate By - Indicates whether the column should be used for aggregation in reports and charts.

Defaults for Tabular Forms

Use Display As to specify how an item should display in a tabular form.

Defaults for Forms

Available Defaults for Forms attributes include:

  • Display - Indicates whether the column displays in a form. The default is Yes.

  • Display Sequence - Specifies the sequence of items in a form. The default is based on the column ID, which is based on the order of the columns in the table.

  • Display As - Indicates how items in a form display. The default selection is Text Field.

  • Mask - Indicates a mask to be applied against the data in a form. Not used for character-based items.

  • Default Value - Specifies the default value associated with this column.

  • Width - Specifies the display width.

  • maxWidth - Specifies the maximum string length a user is allowed to enter in this item.

  • Height - Specifies the display height of an item.

  • Required - Used to generate a validation in which the resulting item must not be null. If resulting item is not null, select Yes.

  • Help Text - Becomes Item help. By default, this text is pulled from the column hint (if applicable).

List of Values

To access List of Values defaults, click the List of Values tab. Once you select the type, you are prompted to enter either Display Value, Return Value pairs, or a list of values query.

The top of the page displays the selected schema, table or view name, and column name. Use the List of Values Type list to specify whether the selected column will include a static or dynamic list of values.

Viewing the Column Definition Report

You can view details about a specific column by accessing the Column Definition report. The Column Definition report displays the data type, data length, nullable, default, comment as well as any check constraints, primary and unique keys, and foreign keys that reference the column.

To view the Column Definition report:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, select User Interface Defaults.

  3. Select a table by clicking the Edit icon adjacent to the table name.

  4. Select a column.

  5. From the Tasks list, select View Column Definition.

Applying User Interface Defaults to a Table or View

You can view a listing of tables without user interface defaults on the Tables without Defaults page.

To apply user interface defaults to a table or view:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, select User Interface Defaults.

  3. From the Tasks list, select Tables without User Interface Defaults.

  4. To apply user interface defaults to a table or view, select the Default link to the left of the table or view name.

Comparing User Interface Defaults Across Applications

Use the Compare Defaults report to monitor consistency in user interface design across all pages in a single application or multiple applications in the current workspace. Running the Compare Defaults report compares currently defined user interface defaults (or column attributes) against the column attributes set for forms, reports, and tabular forms.

To run the Compare Defaults report:

  1. Click SQL Workshop on the Workspace home page.

  2. Under SQL Workshop, select User Interface Defaults.

  3. From the Tasks list, select Compare User Interface Defaults.

    The Compare Defaults page appears.

  4. Select a schema, table name, and column.

  5. From Display, select the attributes you want to compare.

  6. Optionally select an application.

  7. Click Go.

About Exporting and Importing User Interface Defaults

You export user interface defaults in the same way you export any related application file. Exporting user interface defaults from one Oracle HTML DB development instance to another involves the following steps:

  • Export the user interface defaults using the Export User Interface Defaults utility

  • Import the exported file into the target Oracle HTML DB instance

  • Install the exported file from Export Repository

When you export user interface defaults, all user interface defaults for the selected schema are exported to a single script. The file contains an API call to create table hints by making calls to the application PL/SQL API. You can use this file to import user interface defaults to another database and Oracle HTML DB instance.

Browsing the Data Dictionary

Each Oracle database has a data dictionary. An Oracle data dictionary is a set of tables and views that are used as a read-only reference about the database. For example, a data dictionary stores information about both the logical and physical structure of the database. A data dictionary also stores information about valid Oracle database users, integrity constraints for tables in the database, and the amount of space allocated for a schema object as well as how much of it is being used.

To browse the data dictionary:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list, select Query Data Dictionary.

    The Data Dictionary Browser appears.

  3. Click the View icon to display the Query By Example (QBE) form. Use this form to query the Oracle data dictionary for details about database objects.

See Also:

Oracle Database Concepts for more information on the data dictionary

To view data dictionary reports:

  1. Click SQL Workshop on the Workspace home page.

  2. From the Tasks list, select Query Data Dictionary.

    The Data Dictionary Browser appears.

  3. From the Tasks list, select Data Dictionary Reports.