Tables. Quest Software 8.5
Reklama
Reklama
Schema Browser
Tables
This chapter discusses the Tables tab in detail and then summarizes some of the other tabs. Most of the tabs and functions in the Schema Browser operate in a similar way.
The Tables page right-click menu includes an Incrementally Drop Table menu item which is only accessed via this menu.
Incrementally drop table
This lets you drop a large table in steps over a selected number of days so that server performance is not hindered. You can only incrementally drop tables with greater than 200 MB and greater than 1000 extents. If the table is not large enough to drop incrementally, a warning dialog displays.
The steps include a job to truncate the table, jobs to deallocate the unused extents in increments over a number of days, and a job to drop the empty table on the last day.
The Incrementally drop table menu item invokes the Deallocate Table Extents window.
181
Toad
To incrementally drop a table
1.
In the Schema Browser | Tables page, right-click on the table you want to drop.
2.
Select the Incrementally Drop Table menu item.
3.
A confirmation dialog displays. Click Yes. (If the table is not large enough to drop incrementally, a warning dialog will display.)
4.
The Deallocate Table Extents window displays. Select the Begin the
decollation/drop process on date from the calendar dropdown.
The Long date format check box is checked by default. If you prefer the short date format, uncheck the box.
5.
Use the At this time spinner to set the time of day that you want to start the deallocation process.
6.
Use the Over this many days spinner to set the number of days you want the deallocation process to take. The spinner lets you select from 5 to 14 days.
7.
Click Execute. The process is scheduled.
To confirm that the procedure has been scheduled, or to delete the procedure, check the Jobs tab. The last several jobs on the jobs list will be deallocating and dropping the selected table. You can delete the incremental drop by deleting all related jobs in the list.
182
Schema Browser
Objects Panel
Create Script
The Create Script button displays a Table Script Creation window with the
Options tab selected by default.
When you select the Execute button, a script is created for your table that you can then paste into the SQL Editor or elsewhere. NOTE: Most but not all Oracle clauses are not supported for object DDL scripts.
For creating multiple table scripts, see the Database | Export | Table
Scripts menu item.
The Options tab contains many options including Include Schema name,
Include Drop Statement, Sort for Creation, and Script Comments. An Inclusions pane lets you include Table Comments, Private Synonyms, Public Synonyms,
Grants, and more. A Constraints panel lets you include the different types of constraints and has the following radio buttons: List constraints following table columns, Individual 'Alter Table' Commands, and One big 'Alter Table'
Command.
The Output tab lets you output the table script to Clipboard, File(s), or Screen.
Click the Execute button to generate the table script, or click the Cancel button to close the Table Script Creation dialog.
The options selected in the Table Script Creation dialog are saved and restored the next time you create a table script.
Create Table
The Create Table button invokes the Create Table window. You can also access this window from the Create| Table menu item.
This window lets you create a new Oracle table.
Use the dialog to enter the table information, then click the Execute button to create the Table. This is easier than remembering the Oracle syntax for this command.
183
Toad
Alter Table
The Alter Table button invokes the Tables window which lets you drop, modify, and add columns; change storage parameters and data type sizes; add not null constraints; and set unused columns. It is the same window as the Create |
Table window, but you are using it to make modifications. To alter a table, select a table from the objects list and click the Alter Table button. The Table window will automatically display the Schema and the Name for the table you selected.
Export Data
The Export Data function creates "INSERT INTO" SQL statements for the data in the selected table. The Export Data button displays the Data Export window for whatever table is selected from the left panel of the Tables page.
Here, the User Profile object was selected, the Export Data button was clicked, and this was the resulting Data Export window.
The Data Export window supports NUMBER, FLOAT, CHAR, DATE, and
VARCHAR2 object types.
184
Schema Browser
Columns Tab
You can check/uncheck columns you wish to include/exclude. Toad checks all the columns by default.
Exclude Null Columns
If checked, Toad will exclude null columns from the columns clause and the values clause of the "INSERT INTO" SQL statement.
E.g.,
INSERT INTO Foo ( ID ) VALUES (5);
INSERT INTO Foo ( ID, NULL_COL_TEST2 ) VALUES (6, 2);
INSERT INTO Foo ( ID, NULL_COL_TEST ) VALUES (7, 1);
INSERT INTO Foo ( ID ) VALUES (8);
INSERT INTO Foo ( ID ) VALUES (9);
INSERT INTO Foo ( ID ) VALUES (9);
Exclude Primary Key Columns
If checked, your primary key columns will be unchecked. If you then check a primary key column, this box gets unchecked. If you do not have any primary key columns, this choice will not be enabled.
Select All /Unselect All
The Select All and Unselect All buttons let you quickly Select or Unselect all the columns. You can then selectively check/uncheck the columns you want to include/exclude.
Options Tab
Where... clause
The Where clause is optional. You do not have to include a Where clause.
If you include a Where clause, you must include the word "Where" in your statement. Example:
WHERE INVENTORY_NUMBER = 943
Destination
Default - To File
The Destination radio buttons let you choose between To Clipboard or To File.
185
Toad
Filename
The filename area has a drill down button where you can drill down to the desired file. You must supply a file name.
Include Schema/Owner Name in Insert Statements
When this radio button is selected, the Schema or Owner Name will be included in insert statements.
E.g.,
INSERT INTO Schema.Foo ( ID ) VALUES (5);
Insert COMMIT statements every __ rows spinner
This spinner lets you designate how many insert statements to generate before generating a commit statement.
Show Table in ER Diagram
This shows the selected table in an ER Diagram.
Table Privileges
The Table Privileges button activates the Privileges window.
This window lets you view, grant, and revoke privileges for the selected table.
You can view all users and their privileges. If you are not the object owner, you cannot grant privileges that you don't have the grant option for. If you do not have sufficient privileges to alter an object, you will get a warning message, but you will still be able to view everyone's privileges for that object and you will also be able to rearrange columns.
The Revoke All button will revoke all privileges from everyone but you.
You can multi-select users using the <CTRL> key. This is useful when applying changes to multiple users. You can multi-select the users, right-click in the column, and grant or revoke from the right-click menu.
The Show SQL button lets you preview the SQL before applying changes.
You can rearrange columns by clicking and dragging on the column headers.
Grants will be highlighted in blue and admin grants will be highlighted in yellow.
If you only want to see the rows of users who have grants you can check the
Show only users who have grants assigned check box.
186
Schema Browser
Create Constraint
The Create Constraint button activates the Create Constraint window.
Use this dialog to create additional table constraints.
You can also get to this dialog via the Create | Constraint menu item.
You can create:
• Primary Key constraints
• Check constraints
• Unique constraints
• Foreign Key constraints
Analyze Table
Click the Analyze Table button to display the Analyze Tables window.
Use this dialog to analyze the selected table from the tables object list. This collects statistics so that COST based query optimization can be used. So, the optimizer can run better queries.
You can either estimate statistics (faster than compute), compute statistics, or delete current statistics.
To analyze all tables in the current schema or other selected schema, go to the
Tools | Analyze All Tables menu item. This displays a schema dropdown so that you can select which schema tables to analyze all at once.
Add Public Synonym for Table
Click the Add Public Synonym for this Table button, and a confirmation window will appear asking if you want to create a public synonym for the table.
Click Yes to create the synonym or No to Cancel.
187
Toad
Table Filter
The Table Filter button displays the Browser Filters window for the Tables.
The Browser Filters button can be found on the tabs for Tables, Procedures,
Triggers, Views, Synonyms, and Constraints. All the Browser Filter windows have a similar interface.
Browser filters are helpful for schemas that contain a lot of objects- the fewer objects that Toad needs to load, the faster it will execute. For example, you can narrow the focus to only tables whose names begin with EMP and temporarily ignore all other objects in the schema.
After you set your filters, select OK and the browser displays the resulting objects.
To view all the objects again, simply select the filter button, clear the filters by selecting Clear where you have filters, and select OK.
The filter is stored in a file named SCHEMA.FLT in the Toad\User Files folder where SCHEMA is the schema name. Do NOT attempt to edit this file!
You can also use this dialog to set up the default filter which is in force for every new schema.
To set up a default filter, go to View | Browser Filters, and click the Show
Default Filter button. Set up your default filters and press OK to close the window. These filters will be set up by default each time the Schema Browser window is opened.
If you select multiple filters, e.g., table name and tablespace name, then they are joined together with an AND statement in the SQL as opposed to an OR statement in SQL.
Not Like sets up the tablename query like this: [not like KEYWORD%].
188
Schema Browser
Rebuild Table
This button invokes the Rebuild Table window.
Compile Dependencies
If your table is called by a Procedure or View this button will compile those dependencies.
Drop Table
The Drop Table button lets you drop the selected table directly from the Schema
Browser. A confirmation window will ask you if you are sure you want to drop the table. Once you select Yes the table is dropped and cannot be retrieved.
Truncate Table
This lets you truncate a table (delete all the data but maintain the table structure) and either reuse the storage or drop it. The following dialog will display when you select the button.
Once you click the Execute button you can't rollback or undo your choice.
189
Preuzimanje
Reklama