DbSchema Database Designer

DbSchema | Firebird - How to Create a Table?



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. DbSchema Official Documentation: https://www.dbschema.com/documentation/

DbSchema → Your Trusted Partner in Database Design

Simplify complex database workflows and improve productivity with DbSchema's advanced design and management tools

Visual Design & Modeling
Visual Design & Schema Layout

➤ Create and manage your database schema visually through a user-friendly graphical interface.

➤ Easily arrange tables, columns, and foreign keys to simplify complex database structures, ensuring clarity and accessibility.

GIT & Collaboration
Version Control & Collaboration

➤ Manage schema changes through version control with built-in Git integration, ensuring every update is tracked and backed up.

➤ Collaborate efficiently with your team to maintain data integrity and streamline your workflow for accurate, consistent results.

Data Explorer & Query Builder
Relational Data & Query Builder

➤ Seamlessly navigate and visually explore your database, inspecting tables and their relationships.

➤ Build complex SQL queries using an intuitive drag-and-drop interface, providing instant results for quick, actionable insights.

Interactive Documentation & Reporting
HTML5 Documentation & Reporting

➤ Generate HTML5 documentation that provides an interactive view of your database schema.

➤ Include comments for columns, use tags for better organization, and create visually reports.