A newly created database does not have any tables. You can create one or more tables for a database in Senate. This article shows you how to create a table in the database.
Why do I need to create a table in Senate?
Creating a table for your data file allows you to later share a copy of this table in a Workspace within a project on Senate. Within a Workspace, authorized users can easily connect to the AWS Redshift database and query any tables that have been approved for access.
Creating and sharing a table (rather than a data file only in a project) allows authorized users in a Workspace to take advantage of the fast query and computing performance of a Redshift database.
In this article you will learn about
You will have
From the Database Screen, click Create table.
There are two parts to the Add Table screen. The top part is where you enter basic information about the table, while the bottom part is where you create your table columns.
On the Add Table screen:
- Give the table a name. The name must only have lowercase letters, digits and if you need a separator, use the underscore character.
- Type a description of the table.
- Scroll down to Add Columns.
In the Add Columns section:
- Type the name of the first column. Column names must only have lowercase letters, digits.
- Give it a description.
- Select a data type from the list.
Important things to note when creating columns:
- When specifying column names, do not use words reserved for databases, such as ‘date’.
- When adding column descriptions, do not use any special characters, including apostrophes or quotes.
- Make sure the column data type matches the data type in the file you intend to load, otherwise there will be errors when loading data to the table. If in doubt, and if applicable, select the data type ‘string’ to prevent errors when loading data to table.
Add more columns as required.
Click Create table when you have finished adding columns.
The new table is added to the database.
It doesn’t have any rows because we haven’t loaded any data yet.
At this stage, you could add more tables if you want to.
Tips for creating a table
- Use CSV rather than TXT files
- Use STRING rather than VARCHAR or CHAR as the data type.
- Check that columns are added in the correct order, as they appear in the CSV
Can I edit a table?
Once a table is created, the columns cannot be edited. If any changes need to be made to the column name or description, a new table needs to be created to load the data to, and the old table can be deleted if it is no longer required.
If an incorrect file has been loaded to the table, you can empty the table and proceed to load a new file to the table.
Emptying or deleting a table
To delete or empty a table:
Go to the Manage Data section, click Databases.
Click View or Edit Database.
Select ‘Delete table’ or ‘Empty table’ and follow the prompts.