amazon-redshiftHow do I create a schema in Amazon Redshift?
Creating a schema in Amazon Redshift is a simple process. The following example code block shows how to create a simple schema with two tables:
CREATE SCHEMA IF NOT EXISTS myschema;
CREATE TABLE myschema.table1 (
id INTEGER NOT NULL,
name VARCHAR(20) NOT NULL
);
CREATE TABLE myschema.table2 (
id INTEGER NOT NULL,
description VARCHAR(100) NOT NULL
);
This code will create a schema called myschema
with two tables, table1
and table2
. table1
has two columns, id
and name
, while table2
has two columns, id
and description
.
Code explanation
CREATE SCHEMA IF NOT EXISTS myschema;
- This creates a schema calledmyschema
if it does not already exist.CREATE TABLE myschema.table1 (id INTEGER NOT NULL, name VARCHAR(20) NOT NULL);
- This creates a table calledtable1
in themyschema
schema with two columns,id
andname
.CREATE TABLE myschema.table2 (id INTEGER NOT NULL, description VARCHAR(100) NOT NULL);
- This creates a table calledtable2
in themyschema
schema with two columns,id
anddescription
.
For more information on creating schemas in Amazon Redshift, see the Amazon Redshift Documentation.
More of Amazon Redshift
- How do I use the Amazon Redshift YEAR function?
- How can I handle divide by zero errors when using Amazon Redshift?
- How can I use Amazon Redshift and Kinesis together?
- How do I set up Amazon RDS with Multi-AZ for high availability?
- How can I use Amazon Redshift to store and process unstructured data?
- How do I use Amazon Redshift RSQL to query data?
- How do I create a table in Amazon RDS?
- How can I monitor Amazon RDS using Zabbix?
- How do I use Amazon Redshift with YouTube?
- How do I connect to an Amazon Redshift cluster using PostgreSQL?
See more codes...