Create database table

This tutorial is about using Sohag Builder to create a new database table.

Create a MariaDB database connection.

Hit connect button, the first button in the toolbar.

Sohag Builder connect to database

 

In the connection dialog

  • change database type to MariaDB (you may use PostgreSQL, MySQL and SQLite).
  • Add the database name, user name and password.
  • You may change the host and port, or leave the default values.
  • Press connect button to connect to database.

sohag builder dialog create database table

Open new table wizard.

In the database info pane.

Open the context menu (use the mouse right button or the keyboard context menu).

sohag builder create database table

From the table dialog wizard

Leave the schema name empty or you may add the database name in case of using MariaDB or MySQL.

Type the table name.

Adding Table Columns

  • In the column name add "id" ,
  • From the data type select "INT".
  • Check AI checkbox to make the column auto increment column.
  • Press Add/Edit button to add the column.
  • The column details will be added to the columns grid.

Sohag Builder Create database wizard

  • In the column name add "name"
  • Select VARCHAR as data type.
  • In the length add 200, to set the column length to 200 character.
  • Press Add/Edit button to add the column to the columns grid.

Follow similar steps to add column (email VARCHAR(20)). 

Tip

If data type is not included in the Data Type list, just write it.

Sohag Builder create new database table wizard

You can set Primary Key, Not Null, Unique and AI in both column form and columns grid.

To create multiple column primary key by setting primary key checkbox checked in the required columns.

To edit column double click the column in the grid, column data will be pushed to the form, edit the data and then press Add/Edit button.

To remove a column, Select the column in the grid and then press Remove button.

Use the up and down arrows to move columns order up and down consequently.

Note

You can add Primary Key, Unique constraints here in columns tab or in the constraints tab.
Constraints tab let you add constraint name.
Don't add the same constraint in both columns tab and constrains tab, If you did so it will be doublicated  in the generated SQL statement .

Adding Constraints.

Press constraints tab.

Add Primary Key Constraint.

  • Select PRIMARY KEY from the type list.
  • In the constraint name add 'vendors_id_pk', Constraint Name is optional.
  • Select id from the Local Column list.
  • Press Add/Edit button to add the constraint.

Sohag Builder MariaDB add constraints to database table

Repeat the former steps to add constraint.

  • Type: UNIQUE
  • Constraint Name: vendors_email_unq
  • Local Column: email

Sohag Builder Add Unique Constraint

Display and edit SQL statement.

Press SQL tab.

SQL editor contains the generated create table DDL statement.

You can change the generated create table SQL statement as you need.

Any changes in the table will regenerate the create table statement instantaneously.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
4 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
Verion
v1.0