Creating Tables with a Script

From InterBase
Jump to: navigation, search

You’ve created several tables manually now and begin to understand what’s involved. To avoid having to type in all of the table definitions, you should now run the Tables.sql script.

Image 025.jpg Running the Tables.sql Script

Before you leave the topic of tables, look over the remaining table definitions in Tables.sql to be sure that you understand them. Pay particular attention to the Employee table, which is complex and is central to this database. Notice, in particular, the complex CHECK constraint on the salary column in that table. It states that the salary entered for an employee has to be greater than the minimum salary for the employee’s job (specified by job_code, job_grade, and job_country) and less than the corresponding maximum.

  1. In the Interactive SQL dialog, load the Tables.sql script to enter the remaining table definitions into the TUTORIAL database by choosing Query > Load Script.
As before, check first that the database path, user name, and password are correct in the CONNECT statement at the beginning of the file. Then choose Query > Execute.
  1. Click on Tables in the left pane of IBConsole to check that you now have ten new tables in the TUTORIAL database.

    IBConsoleTables2.png

    Note: Time to back up again. If you have successfully run Tables.sql, this is a good time to back up your database to Tutorial2.gbk.

Advance To:

Troubleshooting