Creating Tables
As mentioned previously, an RDBMS stores data in tables that look similar to spreadsheets. Of course, before you can store any data in a database, you need to create the necessary tables and columns to store the data. You do this by using the CREATE
statement.
For example, the cd_collection
table from Figure 29.2 has five columns, or fields: id
, title
, artist
, year
, and rating
.
SQL provides several column types for data that define what kind of data will be stored in the column. Some of the available types are INT
, FLOAT
, CHAR
, and VARCHAR
. Both CHAR
and VARCHAR
hold text strings, with the difference being that CHAR
holds a fixed-length string, whereas VARCHAR
holds a variable-length string.
There are also special column types, ...
Get Ubuntu Unleashed 2014 Edition: Covering 13.10 and 14.04,Ninth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.