home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
- CREATE A TABLE
-
- The create command is used to create a table file.
-
- SYNTAX
- CREATE TABLE table_name (
- column_name data_type column_width
- [column_name data_type column_width]
- ) number_of_rows;
-
- EXAMPLE:
-
- SSQL> create table cust (
- > code char 2
- > name char 15
- > st char 2
- > rating num 2
- > ) 20;
-
- The above definition was used to create the cust table used in the
- documentation. You can define up to 32 columns in a table.
- Once a table is created, you can use the insert command to add
- rows to the table.
-
- table_name
-
- A table name can be from 1 to 8 characters. The first character
- must be a letter of the alphabet. The rest can be letters or
- digits. The table file is created on the disk as
- table_name.SQL. For example, the cust table, created above would
- be stored as CUST.SQL on your disk. However, from SSQL, you would
- always refer to it as cust. Since SSQL adds the extension of SQL
- to all table files, you must not use a period in your table
- name.
-
- column_name
-
- A column name can be from 1 to 10 characters. The first
- character must be a letter of the alphabet. The rest can be
- letters or digits. In creating column names remember that when
- a table is displayed, the full column name is displayed too.
- Long column names tend to fill the screen (or printer) very
- rapidly when you want to display many columns.
-
- data_type and column_width
-
- NUMBERS
-
- The data type num is used for numbers. When you use this data
- type the values are always right-justified (values are pushed to
- the right so all the ones column lines up). Data must be of
- this type in order to use any of the numeric functions such as
- avg, max, min, and sum.
-
-
-
-
- CREATE-1
-
-
-
-
-
- For the data type num, the column width can be from 1 to 10
- digits. Optionally, you can add a decimal indicator for numeric
- functions. For Example:
- cost num 5.2
- This would allow a maximum of 99.99 to be stored in the column
- if you always used the decimals. The ONLY time the number of
- decimal places is checked is when a numeric function takes
- place, NOT when you are entering data. If you have a column
- which stores dollars and cents, remember to always enter the
- cents even if it is "00". This would avoid the problem of
- entering 15 and 23.65 and have the column be displayed as:
- 15
- 23.65
-
- It is allowable to use whole numbers even though you define it
- as having decimals. For example, you want to enter grades
- which are from 0 to 100 but when you calculate grade averages,
- you want it calculated to one tenth of a grade point. You would
- define the column as:
- grade num 3.1
-
- You would enter the grades as whole numbers but when the average
- is calculated, the decimal would be included. The column width
- is increased by five when a numeric function is used. This
- makes it possible to define something like:
- level num 2.4
- You could only enter 1-99, but when the average was calculated,
- it would be to four decimal places.
-
- CHARACTERS
-
- The data type char can be used for any column that is not used
- in a calculation. Although the data is usually a combination of
- alphabetic and numeric data, it is alright if the column just
- contains digits. The characters are left-justified. The
- maximum column width is 80.
-
- number_of_rows
-
- The last item you enter is the maximum number of rows that you
- want in the table. The minimum number of rows is 11. If you
- enter a number less than 11, the table will be created with 11
- rows. The maximum number allowable is 32000.
-
-
-
-
-
-
- CREATE-2
-
-
-
-
-
-
- DETERMINING HOW A TABLE WAS CREATED (The STRUCT command)
-
- In order to display the create command used to create the table,
- type:
-
- STRUCT table_name
-
- where table_name is the name of a table that exists in you
- database. For example, to display the table structure for the
- cust table you would type:
-
- struct cust;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- CREATE-3
-
-