How to create a table within a database in Redshift?

Viewed 132

I did this:-

CREATE DATABASE Cricket; 
CREATE TABLE Cricket.First_Table
(
Player      varchar(30)   default  'Abhay Saini',
Runs        integer(20)   default  '-1',
Minutes     integer(10)   default  '-1',
Batted_Flag integer(10)   default  '-1',
Not_Out     integer(10)   default  '-1',
Balls       integer(10)   default  '-1',
Fours       integer(10)   default  '-1',
Sixes       integer(10)   default  '-1',
Strike_Rate integer(10)   default  '-1',
Innings     integer(10)   default  '-1',
Opposition  varchar(20)   default  '-1',
Ground      varchar(20)   default  'Panchkula'
Date        date          default  '1901-01-01'
Country     varchar(20)   default  'Vatican'
Fifties     integer(10)   default  '-1'
Hundreds    integer(10)   default  '-1'
);

Error is :-

"database cricket does already exists"

if I comment the first line, then the error is

"schema cricket does not exist"

1 Answers

Typically a table exists within a schema which exists within a database. Obviously you already have a database Cricket.

Your “CREATE TABLE Cricket.First_Table” statement is trying to create a table within a schema called Cricket which doesn’t exist, so you need to create that schema first or create the table within a schema that does exist

Related