Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test for object existence in Firebird SQL?

Tags:

firebird

I need to test whether various types of database objects exist in a given database, and I don't know how to formulate these tests in Firebird SQL. Each test has the form "Does object of type X with name Y exist?". For example, I need to test whether a table with a given name exists. The object types I need to test are:

  • Table
  • View
  • Domain
  • Trigger
  • Procedure
  • Exception
  • Generate
  • UDF
  • Role

One can find how to query for a given table on the Internet, but the other types are more difficult to find ...

like image 957
Paul Lalonde Avatar asked Sep 24 '08 13:09

Paul Lalonde


People also ask

How do I use the Firebird ISQL tool?

Invoking IsqlIf the bin is on your path, you may start it by typing isql regardless of your operating system. Example: $ isql Use CONNECT or CREATE DATABASE to specify a database SQL> CONNECT "C:\DATABASES\FIREBIRD\MY_EMPLOYEE. FDB" CON> user 'SYSDBA' password 'secret';

How do I access my Firebird database?

There are three basic mechanisms to get to a Firebird database. You can either use the raw C API interface, an Open Database Connectivity (ODBC) driver, or an OLE DB driver (the latter is used also for ActiveX Data Objects, ADO, access). Using the raw C API allows developers to write portable code.

What SQL does Firebird use?

Firebird is a relational database offering many ANSI SQL standard features that runs on Linux, Windows, and a variety of Unix platforms. Firebird offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers.

How do you create a table in Firebird database?

The first example creates a primary key constraint PK_CUST using an index named IX_CUSTNO: create table customers ( custno int not null constraint pk_cust primary key using index ix_custno, ... This, however: create table customers ( custno int not null primary key using index ix_custno, ...


2 Answers

I think a lot of what you are asking can be found at this forum post. If you want to dive a little deeper, this site seems to have a graphical representation of the tables.

like image 192
Knobloch Avatar answered Oct 21 '22 23:10

Knobloch


It seems like you need to query against the system tables to reliably get that information. Here's a tutorial that looks like it can help:

http://www.alberton.info/firebird_sql_meta_info.html

like image 29
Adam Bellaire Avatar answered Oct 22 '22 00:10

Adam Bellaire