SQL Syntax of INTERBASE/Firebird (favorites)

Source: Internet
Author: User
Tags interbase

Recently, in the group, everyone suddenly discussed that FB (Firebird) was coming. Oh, after reading some information, I suddenly found this thing quite interesting. So I began to look for a lot of relevant information, below are some of the SQL statements in FB, which are transferred from the Internet. You may have a look at them and I will sort them out in a few days. use the FB demo under. Net to show you the support.

I. Paging syntax example:
Select first10 templateid, code, nameFromTemplate;
Select first10Skip10 templateid, code, nameFromTemplate;
Select*FromShopRows1To10; -- firebird2.0 supports this method

Ii. display table name and Table Structure
  Show tables;
Show tableTablename;

3. Use iSQL to connect to the database
Firebird % 92bin> iSQL-u sysdba-P masterkey
SQL>Connect'E: companyxmwsoftnewxmwsoftc2dbcts2. fdb ';
Or
SQL>Connect'E: % 92'
Con>User'Sysdba'
Cont>Password'Masterkey ';

4. Update field comments
UpdateRDB $ relation_fields
SetRDB $ description = 'descriptive information'
Where(RDB $ relation_name = 'shop ')
And(RDB $ field_name = 'credit _ buy ')

5. display field comments
SelectRDB $ field_name, RDB $ description
FromRDB $ relation_fields
Where(RDB $ relation_name = 'shop ')
And(DB $ field_name = 'credit _ buy ')

6. Update Table Comments
UpdateRDB $ relations
SetRDB $ description = 'descriptive information'
WhereRDB $ relation_name = 'table _ name ';

7. query all tables and views (including system tables and system views)
SelectRDB $ relation_name
FromRDB $ relations;

8. query all user tables and user views
SelectRDB $ relation_name
FromRDB $ relations
WhereRDB $ system_flag = 0;

9. query all user tables
SelectRDB $ relation_name
FromRDB $ relations
WhereRDB $ system_flag = 0
AndRDB $ view_blrIs Null;

10. query all fields and definitions in all user tables and user views
Select
A. RDB $ relation_name,
B. RDB $ field_name,
B. RDB $ field_id,
D. RDB $ type_name,
C. RDB $ field_length,
C. RDB $ field_scale
FromRDB $ relations
Inner joinRDB $ relation_fields B
OnA. RDB $ relation_name = B. RDB $ relation_name
Inner joinRDB $ fields C
OnB. RDB $ field_source = C. RDB $ field_name
Inner joinRDB $ TYPES D
OnC. RDB $ field_type = D. RDB $ type
WhereA. RDB $ system_flag = 0
AndD. RDB $ field_name = 'rdb $ field_type'
OrderA. RDB $ relation_name, B. RDB $ field_id;

11. Search for all fields and definitions of a table
Select
A. RDB $ field_name,
B. RDB $ field_type,
B. RDB $ field_length,
B. RDB $ field_precision,
B. RDB $ field_scale
FromRDB $ relation_fields A, RDB $ fields B
WhereA. RDB $ relation_name = 'tablename'
AndA. RDB $ field_source = B. RDB $ field_name
OrderA. RDB $ field_position;

12. Search for the primary key definition field of a table
SelectA. RDB $ field_name
FromRDB $ index_segments A, RDB $ relation_constraints B
WhereB. RDB $ constraint_type = 'Primary key'
AndB. RDB $ relation_name = 'tablename'
AndA. RDB $ index_name = B. RDB $ index_name
OrderA. RDB $ field_position;

XIII. Search for the foreign key definition of a table
Select
R1.rdb $ constraint_name,
Rind. RDB $ field_name,
R2.rdb $ relation_name
From
RDB $ relation_constraints R1,
RDB $ relation_constraints R2,
RDB $ ref_constraints ref,
RDB $ index_segments rind
WhereR1.rdb $ relation_name = 'tablename'
AndR1.rdb $ constraint_type = 'foreign key'
AndR1.rdb $ constraint_name = ref. RDB $ constraint_name
AndRef. RDB $ const_name_uq = r2.rdb $ constraint_name
AndR1.rdb $ index_name = rind. RDB $ index_name;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.