Which clause sets a default value for a column named status to 'active'?

Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

Which clause sets a default value for a column named status to 'active'?

Explanation:
Setting a default value for a column in SQL is done with the DEFAULT clause after the datatype, and string defaults must be written as string literals using single quotes. The correct form defines the column with its type (status VARCHAR(10)) and then assigns DEFAULT 'active'. This ensures that if no value is provided during an insert, the row will automatically use the string active. The other forms fail because they either omit the proper string literal syntax, use double quotes which denote identifiers rather than string literals, or employ an invalid phrase for column defaults.

Setting a default value for a column in SQL is done with the DEFAULT clause after the datatype, and string defaults must be written as string literals using single quotes. The correct form defines the column with its type (status VARCHAR(10)) and then assigns DEFAULT 'active'. This ensures that if no value is provided during an insert, the row will automatically use the string active. The other forms fail because they either omit the proper string literal syntax, use double quotes which denote identifiers rather than string literals, or employ an invalid phrase for column defaults.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy