DbSchema Database Designer

DbSchema | Firebird - How to Create a Table?

Publish on DbSchema Blog >>>

Firebird: How to Create a Table in isql and DbSchema

Firebird alt >

Table of Contents:

  1. Introduction
  2. Prerequisites
  3. Firebird Data Types
  4. Creating a Table in isql
  5. Creating a Table in DbSchema
  6. Conclusion
  7. References

Introduction

Firebird is an open-source SQL relational database management system that runs on Linux, Windows, and several Unix platforms. It offers excellent concurrency, high performance, and powerful language support for stored procedures and triggers. Firebird also provides a command-line tool called isql and graphical interface options like DbSchema.

This article aims to provide a comprehensive guide on creating a table in Firebird using both isql and DbSchema.

Prerequisites

Before diving into the topic, ensure you have the following:

  1. Firebird installed on your local system.
  2. Familiarity with SQL basics and command line.
  3. DbSchema installed for GUI interaction with Firebird.

For installation and establishing connection you can read our article Firebird-How to create a database?

Firebird Data Types

Here is a list of commonly used Firebird data types, alongside their definitions:

Data Type Description
INTEGER 32-bit signed integer.
BIGINT 64-bit signed integer.
FLOAT Approximate numeric with 32-bit precision.
DOUBLE Approximate numeric with 64-bit precision.
DATE Date with the format YYYY-MM-DD.
TIME Time with the format HH:MM:SS.
TIMESTAMP Date and time.
CHAR(n) Fixed-length string with n characters.
VARCHAR(n) Variable-length string with a maximum of n characters.

Creating a Table in isql

isql is the command-line interface that allows you to perform various database operations, such as creating tables, executing queries, and more. It’s a powerful tool especially useful when working with servers or environments without a graphical user interface.

Follow the steps below to create a table using isql:

Step 1: Open the Command-Line Interface or Terminal

This can vary based on your operating system. If you’re on Windows, you can use Command Prompt or PowerShell. If you’re on Linux or macOS, you can use Terminal.

Step 2: Connect to Your Firebird Database

Type in the following command to connect to your Firebird database:

isql localhost:employee.fdb -u SYSDBA -p masterkey

In this command:

  • localhost refers to your server name (replace this with your server’s IP address or hostname if it’s not on your local machine).
  • employee.fdb is your database name.
  • SYSDBA is your username.
  • masterkey is your password.

Press Enter to execute the command.

Step 3: Creating a New Table

Once you’re connected to the database, you can create a new table using the CREATE TABLE SQL statement. Let’s create a table named Students with the following fields: ID, Name, Age, and Grade.

Type in the following command:

CREATE TABLE Students
(
    ID INTEGER,
    Name VARCHAR(50),
    Age INTEGER,
    Grade INTEGER
);

In this command:

  • Students is the name of the new table.
  • ID, Name, Age, and Grade are the columns in the table.
  • INTEGER and VARCHAR(50) are the data types of the columns. INTEGER is used for numerical values and VARCHAR(50) is used for string values of maximum length 50.

After typing the command, press Enter to execute it.

Step 4: Confirm the Table Creation

You can confirm whether your table was created successfully by querying it. Use the SELECT SQL statement to display all records in the Students table:

SELECT * FROM Students;

Since the table is newly created, it won’t have any records yet. But if this command runs without errors, it means your table was created successfully.

Creating a Table in DbSchema

DbSchema is an intuitive GUI tool for designing and managing databases. Here’s how to create a table in Firebird using DbSchema:

  1. Open DbSchema and click on Connect to database.
  2. In the pop-up dialog, select Firebird as your database type, and enter your connection details.
  3. Once connected, click on the Create new table button in the toolbar or right-click on the canvas and select Create Table.
  4. In the new table dialog, enter the table name, e.g., Students.
  5. Add columns by clicking the + button. For each column, you need to specify the name, type, and other attributes. For example, you can add ID, Name, Age, and Grade as column names.
  6. Click OK to create the table. You can view the newly created table in the DbSchema layout.

Create Tables and Visually Manage Firebird using DbSchema

DbSchema is a Firebird client and visual designer. DbSchema has a free Community Edition, which can be downloaded here.

Create Table >

Create Table

Start the application and connect to the Firebird database. Right-click the table folder to create a table.


Add Columns >

Add Table Columns

Add the columns to the table.


Conclusion

Creating a table in Firebird is simple, whether you prefer a command-line tool like isql or a graphical interface like DbSchema. Understanding these steps is vital for managing and manipulating your database effectively. Remember to refer to Firebird’s documentation for a detailed explanation of its data types and functionalities.

References

  1. Firebird Official Documentation: http://firebirdsql.org/manual/
  2. DbSchema Official Documentation: https://www.dbschema.com/documentation/

Visually Manage Databases using DbSchema

DbSchema is a databases client and visual designer. DbSchema has a free Community Edition, which can be downloaded here.
DbSchema main features include:

DbSchema Designer alt >

Interactive Diagrams

Design tables, column and foreign keys directly in diagrams, by double-clicking them. Changes will be saved to the design model and, if DbSchema is connected to the database also into the database. More.


Connection Dialog alt >

Simple Connection Dialog

Choose the database location, the user and password, and simply get connected. Choose 'Edit Manually' into the JDBC URL combo to enter a custom URL. More.


Relational Data Explorer alt >

Relational Data Explorer

Explore data from multiple tables simultaneously, using foreign keys or virtual foreign keys. Double-click cells to edit the data. More.


Query Builder alt >

Query Builder

Create SQL Queries featuring JOINS, GROUP BY, ORDER BY just using the mouse. More.


SQL Query Editor alt >

SQL Query Editor

Edit and execute SQL Queries. The editor is autocompletion-enabled. More.


Schema Synchronization alt >

Design Schema in Team & Schema Deployment

DbSchema is using the design model, a copy of the schema structure, independent of the database.
The design model can be saved to file and shared in a team.
Connecting to another database you may compare the design model with the database, commit the differences or merge them in the design model. More.


Dark Theme alt >

Dark Theme

Configurable styles & dark theme. More.


Many features are available in the free Community edition.
The Pro edition adds capabilities to save the design to the model file, design schema in team and deploy the schema on multiple databases.


DbSchema can be downloaded for free. No registration is required.