Database Tour Documentation Contents Index

Creating Tables

Top Previous Next

To create a table in open database, choose Table | New....

There will be three ways of creating table available:

1. Using a special tool

This way gives you an opportunity to create a table in step by step mode.

-Firstly, you create an array of fields: names, types, sizes, primary key flags etc. Note that some capabilities are not supported for certain table types; in this case, the corresponding columns of the table of fields will be blocked and shown by grey color.
-Then, you specify the table name and click Finish.

If no errors are found, then the specified table will be created and you will see it in the table list to the left of main window; otherwise, you may click Back button, correct erroneous field entries and try again. In the case of continuous error messages, you may go back to the first step, select the third way of creating the table (see 3.), and generate SQL text, correct it manually to avoid the error(s), and create the table by executing the SQL query.

The working with Fields table is very similar to working with database tables in Database Tour. Here are described the hot keys for several most important actions:

Add new entry above current row

CTRL + Insert

Add new entry in the end of table

Move to the last row and press Down Arrow or TAB (if you are in the last column)

Cancel adding new entry

Esc

Delete entry

CTRL + Delete

2. Using SQL

After selecting this option and clicking Next/Finish button, you will be moved to SQL Editor, in which CREATE TABLE template will be shown in it.

Another way of getting the same result is to go to SQL | Edit page, click Templates button right above the SQL editor, and select Create Table template from the dropdown list of SQL templates.

After that, just correct the table and field names in this SQL text and click Execute button. If no errors are found, then the specified table will be created and you will see it in the table list to the left of main window.

3. Using tool to produce SQL

This way will give you an opportunity to specify field names and table name for the new table, as you do in the first way (see above). But after clicking Finish button, the new table will not be created. Instead of this, you will be moved to SQL Editor, in which the SQL text will be generated according to the specified field array and table name. And you will need then to click Execute button by yourself to create the table.

If you have enough experience in SQL, you may check the generated SQL and correct it if you wish before executing the query; otherwise this will be a good way to learn SQL for creating tables.

Note

1.In some databases (for example, folder based databases, opened by BDE), at the second step you will need also to select a type of table to be created (e.g. dBase, Paradox, ASCII).
2.For folder based databases, specify table name without full file path. In some cases (for example, databases for Microsoft Text Driver) you need to add a file extension (.txt, .csv. etc.).
3.Each database type has its own rules for naming fields and tables, their own field types available etc. To learn these rules, please read the documentation for your database. Here are some common recommendations:
 1.For dBase table, the maximum length of field name is 10.
 2.For Paradox table, the maximum length of field name is 25.
 3.For Oracle table, the maximum length of field name is 30.
 4.For SQL Server table, the maximum length of field name is 128.
 5.For DB2 table, the maximum length of field name is 128.
 6.For most of database types, try to avoid spaces, special characters like ^, *, ! etc. in the field and table names.
 7.For most of database types, try to avoid non-English characters in field and table names.
 8.For some database types, you should specify non-zero field size for all field types; but in some database types, you should specify field sizes only for some field types like String, Memo, Bytes etc., and should leave field size as 0 for other field types like Integer, Float, SmallInt etc.

See also

 How to start