Add, Edit, Delete global having conditions as per the toolbar.
The Add and Edit buttons open the Global HAVING Definition dialog. Global Having entries are in the form of <expression1> <operator> <expression2>.
|
TIP: You could alternatively populate the HAVING clause via the Criteria Tab. First set a GROUPed BY field. Then set the Having clause for that field by entering it in the group cond. row. This has the limitation that you can only have the selected field on the left side of the relational operator. If you need to have multiple fields on that side of the operator, use the Global Having feature. |
Example
Construct the following query
SELECT emp.empno, emp.ename, emp.job, emp.mgr, emp.sal,
emp.comm, emp.deptno
FROM emp
GROUP BY emp.deptno, emp.comm, emp.sal, emp.mgr, emp.job,
emp.ename, emp.empno
HAVING ((emp.sal + NVL (emp.comm, 0) > 4000))
Follow the numbered steps
- Open the SQL Modeler (as SCOTT/TIGER).
- Double-click EMP to add it to the model.
- Right-click EMP and choose Select All, then deselect Hiredate.
- In the Criteria tab, double-click the Group By field for DEPTNO.
- Double-click the Group By fields for COMM, SAL, MGR, JOB, ENAME and EMPNO as well.
- Click the Global Having button in the toolbar. Click the Add button to add a new Having clause.
- Enter the Having clause to say:
- EMP.SAL + NVL(EMP.COMM, 0) > 4000
- Click OK.
View the generated query.
It should appear as described above. This query selects all the employees whose salary plus commission is greater than 4000. The NVL command substitutes a null value in the specified column with the specified value, in this case, 0.
Use the model area to visually join or manipulate the Tables, Views and Synonyms.
Add objects
Show/Hide the Table Selector on the SQL Modeler Toolbar. It lists the tables, views and synonyms available to you for inclusion in your SQL Model. Double-click each desired Table, View, Synonym, OR drag and drop them from the list to the model area. As the objects are presented on the model area, join lines are drawn from any established foreign keys in the DDL.
Additionally, drag-and-drop objects from:
|
TIP:
- To open SQL Modeler with a table, select the table in DB Navigator then click Object Menu | SQL Modeler.
- You can click in a table header and drag and drop the table where you want it in the Model Area.
|
Build a query
Clear an existing query from the Model Area, if required. |
Click New Model on the SQL Modeler Toolbar. |
Define the type of statement you want to create. |
Choose SELECT, UPDATE, DELETE, or INSERT from the SQL Modeler Toolbar. |
Add objects to the Model Area. |
Drag and drop Tables, Views, or Synonyms from the Table Selector to the modeling area.
You can show/hide the Table Selector on the SQL Modeler Toolbar. |
Specify table columns to be used in the query. |
Select column names in the tables in the Model Area.
|
Note: If no table columns are selected, then all columns will be included in the query. | |
Set criteria for the query |
See the Criteria Tab. |
View your query as SQL code or as a data grid. |
Click the Generated Query Tab and Query Results Tab. |
Save the model |
Save the model from the SQL Modeler Toolbar. |
Create a table join
- Add two table names to the Model Area.
- In the first table, click the column name that you want to join. Drag it to the corresponding column name in the second table.
- When the join is successfully created, SQL Modeler draws a connecting line that represents the join between the two table columns.
|
TIP: To specify criteria for a table join, double-click on the connecting line joining the two columns. This opens the View Joins Dialog. |
Menus in the Model Area
Right click the model
Copy Model Image To Clipboard |
Copy a bitmap image of the model to the Windows Clipboard |
Tables |
Visibility |
Show / Hide tables in the model.
Hidden tables are not included in the Generated Query (Generated Query Tab). |
Calculated Fields |
Add calculated fields based on other table columns. | |
Show |
Join Text |
Show the column names that comprise the joins. |
Adjust Model Origin |
Move the model so the upper left object is in the upper left of the Model Area. |
Primary Key |
Show the Table Primary Keys. Show PK next to each Primary Key column. |
Indexes |
Show the Table Indexes. Show IDX next to each Index column. |
Show Field Type |
Show the column data type in each table. | |
SQL |
Run Query in Thread |
Run the query in a way that allows you to halt it in the middle if necessary. |
Global Where Clauses |
Open the Global WHERE Conditions Window. Use to add a WHERE clause to the query. |
Global Having Clauses |
Open the Global HAVING Conditions Window. Use to add a HAVING clause to the query.
|
Query Variables |
Add variables. These variables are used in the Global WHERE Definition Dialog and Global HAVING Definition Dialog. | |
Auto Join All Objects |
Join all tables based on DDL Foreign Key Constraints. |
Hide fields |
Show / Hide the list of columns in the table in the model area. |
Zoom to table |
Select a table to focus. |
Toggle Full Screen Mode |
Show / Hide the Table Select List and Criteria/Generated Query/Query Results tabs. |
Optimize All Table Sizes |
Minimize the size of the tables in the Model Area. |
Arrange Tables |
Arrange the tables in the Model Area. |
Right click the Table object
Set Table Alias |
Set the Table Alias. The value is added to the Criteria Tab. |
Alias Field Names |
Set the Field Alias for each column in the table. The values are added to the Criteria Tab. |
Auto Join |
Automatically join this table to others based on DDL Foreign Key Constraints. |
Show Schema Name in SQL |
Shows / Hide the schema name in the Generated Query (Generated Query Tab). |
Remove Table |
Remove this table from the model. |
Select All |
Select / unselect columns in the table. |
Unselect All |
Invert Selection |
Optimize Size |
Restore the size of the table to its default size. |
Hide |
Temporarily hide the table from the model.
While the table is hidden it will not be included in the Generated Query (Generated Query Tab).
|
TIP: To hide multiple tables or show hidden tables, right click on the Model Area and select Tables | Visibility. | |
Keyboard Shortcuts
Up and down arrow keys |
Move you around in lists |
Space bar |
Select / Unselect boxes |
Tab |
Move forward one area (table, menu, list, etc) |
Shift-Tab |
Move back one area (table, menu, list, etc) |
Modules, Windows And Dialogs > SQL Modeler
The SQL Modeler provides a fast means for creating the framework of a Select, Insert, Update, or Delete statement. You can select Tables, Views or Synonyms, join columns, select columns, and create the desired type of statement.
Model Area |
Used to graphically lay out a query. |
SQL Modeler Toolbar |
Most frequently used Modeler functions. |
Criteria Tab |
Criteria used in generating the model. |
Generated Query Tab |
Automatically generated SQL as a result of the model. |
SPLITTERS |
The SQL Modeler has two splitters to change how you divide the screen.
- There is a horizontal splitter between the Model Area and the Criteria/Generated Query/Query Results tabs. Drag it up or down and release to see more or less detail.
- There is a vertical splitter between the Model Area and the Table Selector List. Drag it left or right to see more or less detail.
|