SQL Database Structure
The SQL database structure consists of one or more tables. Each table is contained in a file. Tables are defined by rows and columns.
Column 1 | Column 2 | Column 3 | Column 4 |
Row 1 |
- row- record - Information about a specific object such as a person.
- column -field - category of information
- key - A unique value in a table that is used to identify that particular object/
SQL Create Command
This command is used to create a table. The syntax of this command is:
create table tablename
(column1name datatype [constraint],
column2name datatype [constraint],
column3name datatype [constraint]);
Keywords specifying Items that may be created
- table
Data Types
- char(size) - Fixed length string of characters of the set size. The size of the string is limited to 255 characters.
- date
- number(maxsize) - Number with a maximum number of digits specified by "maxsize".
- number(maxdigits,maxright) - A decimal number with a manimum number of "maxdigits" with "a maximum number of digits to the right of the decimal, "maxright".
- varchar(maxsize) - A character string with variable lingth limited to "maxsize".
Constraints
Constraints are rules for the column.. Possible values include:
- not null - The column values must have a value and cannot be null.
- primary key - Each record is uniquely identified by this column.
- unique - No two values may be the same in the column
Example
create table citylist
(name varchar(20),
state varchar(20),
population number(8),
zipcode number(5) unique);
No comments:
Post a Comment