0
0
PostgreSQLquery~10 mins

Variable declaration and assignment in PostgreSQL - Interactive Code Practice

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

Complete the code to declare a variable named counter of type integer.

PostgreSQL
DECLARE counter [1];
Drag options to blanks, or click blank then click option'
ABOOLEAN
BTEXT
CINTEGER
DDATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT instead of INTEGER for numeric variables.
Forgetting the semicolon at the end.
2fill in blank
medium

Complete the code to assign the value 10 to the variable counter.

PostgreSQL
counter [1] 10;
Drag options to blanks, or click blank then click option'
A<-
B:=
C==
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of := for assignment.
Using == which is not valid in PostgreSQL.
3fill in blank
hard

Fix the error in the variable declaration to declare username as a text variable.

PostgreSQL
DECLARE username [1];
Drag options to blanks, or click blank then click option'
AINT
BVARCHAR
CBOOLEAN
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Using INT for text variables.
Using BOOLEAN instead of a string type.
4fill in blank
hard

Fill both blanks to declare a variable total as integer and assign it the value 0.

PostgreSQL
DECLARE total [1];
BEGIN
  total [2] 0;
END;
Drag options to blanks, or click blank then click option'
AINTEGER
B=
C:=
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of := for assignment.
Declaring the variable as TEXT instead of INTEGER.
5fill in blank
hard

Fill all three blanks to declare a variable flag as boolean, assign it true, and then reassign it false.

PostgreSQL
DECLARE flag [1];
BEGIN
  flag [2] TRUE;
  flag [3] FALSE;
END;
Drag options to blanks, or click blank then click option'
ABOOLEAN
B:=
C=
DINTEGER
Attempts:
3 left
💡 Hint
Common Mistakes
Using = instead of := for assignment.
Declaring the variable as INTEGER instead of BOOLEAN.