Working with tables

Creating a table

Create Table Tool

The Create Table Tool (available from the Schema menu) provides a graphical way to create a table. It allows you to specify the creation parameters, and then executes the CREATE TABLE sql statement for you.

The first step in creating a table is to select which database it should be a part of. You do this by selecting a database name from the menu at the top (with certain types of database this might not be necessary, and in this case the menu will not appear). Then you should give your table a name.

Next up is the process of adding columns. The table's columns are listed on the left as you add them, and you can use this list to reorder them (via drag & drop), delete them (if you've changed your mind), or select them to change thier attributes.

Column attributes

For each column, you can specify the following information:

Name
The name of the column. Column names are normally limited to letters, numbers, and the underscore character.
Data type
What type of data is stored in the column. This popup menu will list all the data types of the server you are connected to that MacSQL supports.
Size
For text and blob fields, this is the maximum length that can stored in that field. For other fields, this value's meaning is server specific.
Scale
For decimal numbers, the number of digits to the right of the decimal.
Default
The default value to use when an insert does not specify a value for this column.
Not Null
If checked, this column must have a value and can not be left as null.
Auto-increment/Identity
The name of this column will vary based on what type of server you are connected to. If checked, a unique value will automatically be generated for each row that is inserted. Only one such column can be inserted per row and is automatically made the primary key.
Primary Key
If checked, this column will be part of the primary key that is used to uniquely distinguish each row.
Unsigned
If checked, the column will only accept unsigned integer values. This option may not be supported for all servers and data types.

Create the table

When you are satisifed with your table, click the Create Table button. This will first perform some basic checks (for example, to make sure you aren't using a reserved word for a table or column name) and if all is well, MacSQL will send the CREATE TABLE statement to the server and display the new table in the schema viewer.


Table of Contents