![]() (If you know C, this is not unlike the C syntax for initializing structures.) You can put double quotes around any element value, and must do so if it contains commas or curly braces. To write an array value as a literal constant, enclose the element values within curly braces and separate them by commas. ![]() ![]() pay_by_quarter could have been defined as:Īs before, however, PostgreSQL does not enforce the size restriction in any case. So, declaring the array size or number of dimensions in CREATE TABLE is simply documentation it does not affect run-time behavior.Īn alternative syntax, which conforms to the SQL standard by using the keyword ARRAY, can be used for one-dimensional arrays. Arrays of a particular element type are all considered to be of the same type, regardless of size or number of dimensions. The current implementation does not enforce the declared number of dimensions either. However, the current implementation ignores any supplied array size limits, i.e., the behavior is the same as for arrays of unspecified length. The syntax for CREATE TABLE allows the exact size of arrays to be specified, for example: The above command will create a table named sal_emp with a column of type text ( name), a one-dimensional array of type integer ( pay_by_quarter), which represents the employee's salary by quarter, and a two-dimensional array of text ( schedule), which represents the employee's weekly schedule. To illustrate the use of array types, we create this table:Īs shown, an array data type is named by appending square brackets ( ) to the data type name of the array elements.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |