I would like to insert the contents of the text file users.dat into the table t1 using psql. Contents of text file
users.dat:
Definition of table t1:
CREATE TABLE t1 (uname TEXT, pass TEXT, id INTEGER); Select the most appropriate input from those
below.
A. \copy t1 FROM users.dat WITH DELIMITER ':'
B. \copy t1 TO users.dat WITH DELIMITER ':'
C. INSERT INTO t1 FROM file('users.dat');
D. INSERT INTO t1 SELECT uname, pass, id FROM file('users.dat');
E. \insert t1 FROM users.dat WITH DELIMITER ':';
Select the correct SQL statement that records the space occupied by deleted or updated rows for later reuse, and also updates statistics.
A. VACUUM
B. VACUUM ANALYZE
C. EXPLAIN
D. EXPLAIN ANALYZE
E. NOTIFY
Select the SQL command that must be executed prior to executing the EXECUTE command.
A. CREATE FUNCTION
B. PREPARE
C. DECLARE
D. LOAD
E. ALLOCATE
The table "tbl" is defined below such that it could only store non-negative integers in the column "nn". Select the keyword that is applicable for the underlined blank. CREATE natural_number AS DECIMAL CHECK (VALUE >= 0); CREATE TABLE tbl(nn natural_number);
A. VIEW
B. SCHEMA
C. RULE
D. TYPE
E. DOMAIN
Select one incorrect description regarding the following SQL statement defining a function. CREATE OR REPLACE FUNCTION get_file_list(TEXT, BOOLEAN) RETURNS SETOF TEXT LANGUAGE C STRICT SECURITY DEFINER AS 'myfuncs.so';
A. This function may be defined in 'myfuncs.so'.
B. This function can return multiple rows.
C. This SQL statement defines a function written in the C language.
D. If this function is called with a NULL parameter, it will return 0 when executed.
E. This function operates with the authority of the user who executed it.
The following SQL defines an INSERT with respect to item_view. Select the keyword that is applicable in the underlined blank. CREATE foo AS ON INSERT TO item_view DO INSTEAD INSERT INTO item_table VALUES (NEW.id, NEW.itemname);
A. RULE
B. VIEW
C. TRIGGER
D. FUNCTION
E. CONSTRAINT
Select one incorrect statement concerning the following SQL statement. CREATE OR REPLACE VIEW sales_view AS SELECT * FROM sales_table ORDER BY sales_date DESC LIMIT 10;
A. Defines the view called "sales_view".
B. Replaces "sales_view" if it already exists.
C. When you 'SELECT' the "sales_view", it displays the first 10 records from the "sales_table" sorted by the "sales_date" column in descending order.
D. Some errors occur when "SELECT * FROM sales_table" is executed after the view is defined.
E. You can confirm that the "sales_view" has been added by querying the view called "pg_views".
The table "custom" is defined below. The "id" column and "introducer" column are of INTEGER type, and the "email" column is of TEXT type. id | email | introducer ----+-----------------+-----------2 | [email protected] | 1 3 | [email protected] | 2 4 | [email protected] | 2 Three SQL statements were executed in the following order: UPDATE custom SET email = '' FROM custom c WHERE custom.introducer = c.id; UPDATE custom SET introducer = NULL WHERE introducer NOT IN (SELECT id FROM custom); DELETE FROM custom WHERE id = 2 OR introducer = 2; Select the number of rows in the "custom" table after the execution.
A. 0 rows
B. 1 row
C. 2 rows
D. 3 rows
E. 4 rows
The following table called company is defined as follows:
id | name
----+-----------------1 | Pgsql,inc.
2 | Postgres Co.,Ltd
3 | SQL Company.
Select the most appropriate psql command for generating a text file company.txt with the following content
on the client side.
1,Pgsql \,inc.
2,Postgres Co. \,Ltd
3,SQL Company.
A. \copy company TO 'company.txt' WITH ',';
B. \copy company TO 'company.txt' WITH DELIMITER AS ',';
C. \copy company TO 'company.txt' DELIMITER ','
D. \copy company TO "company.txt"
E. \copy company TO company.txt CSV
Select two commands below from which privileges cannot be changed by the GRANT and REVOKE statements.
A. SELECT
B. VACUUM
C. DELETE
D. TRIGGER
E. DROP