Subject | Re: [Firebird-Java] system tables |
---|---|
Author | Roman Rokytskyy |
Post date | 2008-11-08T07:01:02Z |
Hi,
methods getProcedureSourceCode, getTriggerSourceCode, getViewSourceCode
calls - it is the easiest way.
If you want to avoid importing Firebird packages, tell me, I will
provide you queries
FirebirdPreparedStatement respectively and use methods:
FirebirdStatement.getLastExecutionPlan()
FirebirdPreparedStatement.getExecutionPlan()
FirebirdResultSet.getExecutionPlan()
There is no SQL statement to return the execution plan, works only via API.
DatabaseMetaData? What does not fit your requirements?
A bit different query for check contraint, but you see what you need
(copying them from other place)
Check constraints per table:
private static final String GET_CHECK_CONSTRAINTS = ""
+ "SELECT "
+ " rc.rdb$constraint_name AS CHECK_CONSTRAINT_NAME "
+ ", tr.rdb$trigger_source AS CHECK_CONSTRAINT_SOURCE "
+ "FROM "
+ " rdb$triggers tr "
+ "INNER JOIN "
+ " rdb$check_constraints cc "
+ "ON "
+ " cc.rdb$trigger_name = tr.rdb$trigger_name "
+ "INNER JOIN "
+ " rdb$relation_constraints rc "
+ "ON "
+ " cc.rdb$constraint_name = rc.rdb$constraint_name "
+ "WHERE "
+ " rc.rdb$constraint_type = 'CHECK' "
+ "AND "
+ " rc.rdb$relation_name = ?";
query = "SELECT rdb$generator_name AS " + SEQUENCE_NAME + " " +
"FROM rdb$generators " +
"WHERE rdb$system_flag = " + (systemSequences ? '1' : '0');
($FIREBIRD/examples/empbuild).
we have new one, but this one is quite ok.
Thanks for your efforts in this direction!
Roman
> For further integrating Firebird with DbSchema, I would like to ask:Cast the DatabaseMetaData object to FirebirdDatabaseMetaData and use
> I need some queries to read:
> 1. for views: view_name, view_source_query
> 2. for procedures, triggers and functions: name, source_query
methods getProcedureSourceCode, getTriggerSourceCode, getViewSourceCode
calls - it is the easiest way.
If you want to avoid importing Firebird packages, tell me, I will
provide you queries
> 3. is the explain plan working with 'explain plan ....' ? Which is the correct way of getting the execution plan ?Cast Statement or PreparedStatement to FirebirdStatement or
FirebirdPreparedStatement respectively and use methods:
FirebirdStatement.getLastExecutionPlan()
FirebirdPreparedStatement.getExecutionPlan()
FirebirdResultSet.getExecutionPlan()
There is no SQL statement to return the execution plan, works only via API.
> 4. for table constraints and check constraints, the table_name, constraint_name, constraint_bodyAre primary and foreign keys and unique constraints not available via
DatabaseMetaData? What does not fit your requirements?
A bit different query for check contraint, but you see what you need
(copying them from other place)
Check constraints per table:
private static final String GET_CHECK_CONSTRAINTS = ""
+ "SELECT "
+ " rc.rdb$constraint_name AS CHECK_CONSTRAINT_NAME "
+ ", tr.rdb$trigger_source AS CHECK_CONSTRAINT_SOURCE "
+ "FROM "
+ " rdb$triggers tr "
+ "INNER JOIN "
+ " rdb$check_constraints cc "
+ "ON "
+ " cc.rdb$trigger_name = tr.rdb$trigger_name "
+ "INNER JOIN "
+ " rdb$relation_constraints rc "
+ "ON "
+ " cc.rdb$constraint_name = rc.rdb$constraint_name "
+ "WHERE "
+ " rc.rdb$constraint_type = 'CHECK' "
+ "AND "
+ " rc.rdb$relation_name = ?";
> 5. for sequences the sequence_nameSequences:
query = "SELECT rdb$generator_name AS " + SEQUENCE_NAME + " " +
"FROM rdb$generators " +
"WHERE rdb$system_flag = " + (systemSequences ? '1' : '0');
> Do you have any test database on your site or in the installation package ? We would like to point in the documentation to such a database.It is EMPLOYEE.FDB in the Firebird installation directory
($FIREBIRD/examples/empbuild).
> The the first-time-users would be able to connect to this one only in few steps.Yes, this is exactly the case. It might happen that in the next release
> It would be nice if the database may have few more tables, with some data records, and also views, procedures, triggers, etc.
we have new one, but this one is quite ok.
Thanks for your efforts in this direction!
Roman