0
0
PostgreSQLquery~10 mins

CREATE TABLE with PostgreSQL types - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a table named 'users'.

PostgreSQL
CREATE TABLE [1] (id SERIAL PRIMARY KEY);
Drag options to blanks, or click blank then click option'
Ausers
Bcustomers
Corders
Dproducts
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a table name different from 'users'.
Leaving the table name blank.
2fill in blank
medium

Complete the code to define a column 'email' with type for text data.

PostgreSQL
CREATE TABLE users (email [1] NOT NULL);
Drag options to blanks, or click blank then click option'
ABOOLEAN
BVARCHAR(255)
CINTEGER
DDATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using INTEGER or BOOLEAN for text data.
Forgetting to specify a type.
3fill in blank
hard

Fix the error in the column definition for 'created_at' to store date and time.

PostgreSQL
CREATE TABLE users (created_at [1]);
Drag options to blanks, or click blank then click option'
ATEXT
BINTEGER
CTIMESTAMP
DBOOLEAN
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT or INTEGER for date/time data.
Using BOOLEAN which is for true/false values.
4fill in blank
hard

Fill both blanks to create a table with 'id' as primary key and 'price' as decimal.

PostgreSQL
CREATE TABLE products (id [1] PRIMARY KEY, price [2]);
Drag options to blanks, or click blank then click option'
ASERIAL
BVARCHAR(100)
CDECIMAL(10,2)
DBOOLEAN
Attempts:
3 left
💡 Hint
Common Mistakes
Using VARCHAR for price instead of DECIMAL.
Using BOOLEAN for price.
5fill in blank
hard

Fill all three blanks to create a table 'orders' with 'order_id' as primary key, 'order_date' as date, and 'is_paid' as boolean.

PostgreSQL
CREATE TABLE orders (order_id [1] PRIMARY KEY, order_date [2], is_paid [3]);
Drag options to blanks, or click blank then click option'
ASERIAL
BDATE
CBOOLEAN
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT instead of DATE or BOOLEAN.
Not setting primary key correctly.