Computer Knowledge
Database and SQL
3,929 Questions
Master structured query language commands, database joins, table constraints, and alias generation. This section covers relational database management concepts and query outputs essential for technical aptitude. These technical questions feature prominently in banking IT officer exams and computer knowledge sections.
SQL queries and aliasesDatabase table constraintsDatabase joins and transformationsStored procedures and functions
Database and SQL Questions
-
Default constraint
-
Column data type
-
Column name
-
Table name
A
Correct answer
Explanation
When creating a table, the table name, column names, and column data types are all required - a table cannot exist without them. A default constraint is optional because columns can be created without default values. NULL/NOT NULL is also optional but not listed among the choices.
-
Index
-
Check constraint
-
Default constraint
-
Referential constraint
C
Correct answer
Explanation
A default constraint only provides a fallback value when no value is specified - it doesn't restrict which values can be inserted. Check constraints restrict values to specific conditions. Referential constraints (foreign keys) restrict values to existing values in another table. Indexes can enforce uniqueness via unique constraints but don't restrict values otherwise.
-
When it is created
-
When it is referenced in an INSERT statement
-
Any time an executable SQL statement references it
-
The first time any executable SQL statement references it
C
Correct answer
Explanation
Views are virtual tables that don't store data - they execute the underlying query each time they're referenced. A view populates dynamically whenever any executable SQL statement (SELECT, INSERT, UPDATE, DELETE) references it. Views don't cache results and don't populate at creation time.
B
Correct answer
Explanation
The answer is False because while rowid provides fast access, it's not recommended as a primary key in NPS. Rowids can change during operations like DELETE and INSERT, making them unreliable as permanent identifiers. Best practice is to use explicit surrogate keys or natural keys that remain stable. Rowid is useful for performance but not as a primary key.
B
Correct answer
Explanation
The statement is False because NPS doesn't support this ALTER TABLE syntax. NPS has limited ALTER TABLE capabilities and doesn't allow adding columns with this syntax. In NPS, you typically need to recreate the table to add columns. The statement looks like SQL from other databases but doesn't work in NPS.
B
Correct answer
Explanation
This is a duplicate of question 134914 testing the same concept. The statement is False because NPS doesn't support this ALTER TABLE syntax for adding columns. NPS has limited DDL support compared to standard SQL databases.
B
Correct answer
Explanation
In Netezza (NPS), the standard SQL command to rename a table is ALTER TABLE customer RENAME TO customer_new. The syntax RENAME TABLE customer TO customer_new is invalid and will result in a syntax error, making the statement false.
-
single quote
-
semicolon
-
double quote
-
colon
B
Correct answer
Explanation
The semicolon is the standard SQL command terminator in nzsql (Netezza's SQL interface, similar to PostgreSQL). It signals to the SQL parser that the command is complete and ready for execution. Quotes are for string literals, not command termination.
B
Correct answer
Explanation
In nzsql, \dpu (display permissions for users) shows user permissions. Other options serve different purposes: \du lists users (PostgreSQL-style), \dt lists tables, and \d describes database objects. Only \dpu specifically displays permission information.
B
Correct answer
Explanation
The SQL syntax is incorrect for Netezza. The parentheses around the column definition are wrong. The correct syntax should be: ALTER TABLE customer ADD COLUMN newcol char(10); (no parentheses around column name and type).
B
Correct answer
Explanation
The RENAME TABLE syntax is incorrect for Netezza. The proper syntax uses ALTER TABLE with RENAME TO clause: ALTER TABLE customer RENAME TO customer_new; Netezza does not support the RENAME TABLE statement shown.
B
Correct answer
Explanation
The RENAME TABLE syntax is incorrect for Netezza SQL. The correct command uses ALTER TABLE with the RENAME TO clause: ALTER TABLE customer RENAME TO customer_new; The statement as written will not execute successfully.
B
Correct answer
Explanation
The SQL syntax shown is incorrect. Netezza's ADD COLUMN syntax does not use parentheses around the column definition. The correct syntax is: ALTER TABLE customer ADD COLUMN newcol char(10); (without parentheses wrapping the column specification).
A
Correct answer
Explanation
In NPS (Netezza Performance Server), the nzsql \d command describes database objects like tables. The example correctly shows that \d customer will display the customer table's structure. This is standard psql/nzsql behavior for object introspection.
B
Correct answer
Explanation
D-List itemnames CAN be imported directly from database tables. Cognos Analyst provides import functionality where you can map database columns to D-List items, pulling values directly from external data sources. This is a common practice when populating planning models with existing master data from operational systems. The statement claims they cannot be imported, which is false.