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.
|
From this dialog you can see individual joins, browse through the joins, and make changes to the joins.
From / To |
The join fields, joined from one table to another. |
Join Type |
You can change the Join Type from Inner to Outer. The line color denotes the type of join. |
Outer Join On |
If you have selected an Outer join, you can change which table the outer join is performed on. |
Join Test |
You can change the test for the join.
You can make it Less than, Greater than, etc. instead of Equal to. |
Buttons |
Previous Join |
Delete the current join. |
Next join |
Move forward in the join list. |
Delete Join |
Move backward. |
OK |
Close the window and return to the SQL Modeler. | |
To open this dialog, click View Joins on the SQL Modeler toolbar. Alternatively, double click on a join line in the Model Area.
Add, Edit, Delete global where conditions as per the toolbar.
The Add and Edit buttons open the Global WHERE Definition dialog. Global Where entries are in the form of <expression1> <operator> <expression2>.
|
TIP: You could alternatively populate the WHERE clause via the Criteria Tab. Entries into the cells of the Criteria tab should be in the form of <operator> <expression2>. |
Example
Construct the following query
SELECT dept.deptno, dept.dname, dept.loc
FROM scott.dept
WHERE ((dept.deptno BETWEEN 1 AND 25)
AND (dept.deptno < 40)
AND (dept.loc IS NOT NULL)
Follow the numbered steps
- Open the SQL Modeler (as SCOTT/TIGER).
- Double-click DEPT to add it to the model.
- Right-click DEPT and choose Select All.
- On the criteria tab, double click the Where Cond. cell under DEPTNO.
- Choose < and fill in the value 40. Click OK.
- On the criteria tab, double click the Where Cond. cell under LOC and then choose the Expert tab and click Yes at the warning dialog.
- In the top edit box, enter IS NULL. Click OK.
- On the criteria tab, double-click the OR cell under LOC. Choose the Expert tab and click Yes at the warning dialog.
- In the top edit box, enter = 'CHICAGO'
- In the table model area (the area around the table images), right-click and choose SQL>Global Where
- In the top edit box, enter Data Field DEPT.DEPTNO. Click OK.
- From the SQL Function panel, select BETWEEN _Const_ AND _Const_. Replace the constants with values, for example 1 and 25 respectively. Click OK twice.
- View the generated query. It should appear as described above.