Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

Step 3: Create a Database Table

After you create your new database, you create tables to hold your database data. You specify any column information for the table when you create the table.

For example, to create a table named testtable with a single column named testcol for an integer data type, issue the following command:

Copy
create table testtable (testcol int);

The PG_TABLE_DEF system table contains information about all the tables in the cluster. To verify the result, issue the following SELECT command to query the PG_TABLE_DEF system table.

Copy
select * from pg_table_def where tablename = 'testtable';

The query result should look something like this:

Copy
schemaname|tablename|column | type |encoding|distkey|sortkey | notnull ----------+---------+-------+-------+--------+-------+--------+--------- public |testtable|testcol|integer|none |f | 0 | f (1 row)

By default, new database objects, such as tables, are created in a schema named "public". For more information about schemas, see Schemas in the Managing Database Security section.

The encoding, distkey, and sortkey columns are used by Amazon Redshift for parallel processing. For more information about designing tables that incorporate these elements, see Best Practices for Designing Tables.