example of table literal - sqlexample a table


Example of Table Literal - SQL

Example: A Table Literal (correct version)

VALUES

('S1', 'C1', 'Anne'),

('S1', 'C2', 'Anne'),

('S2', 'C1', 'Boris'),

('S3', 'C3', 'Cindy'),

('S4', 'C1', 'Devinder')

Now, the question arises, what is the (table) type of the table shown in Example? For that matter, what is the (row) type of ('S1', 'C1', and 'Anne')? In particular, what are the field names of those three fields, which would become column names for the containing table? The short answer is that they are determined by the context in which the expression appears. Because the components are distinguished anyway by ordinal position, the field names sometimes serve little or no purpose. In fact several fields are permitted to acquire the same name. Also, sometimes the context does not provide any names at all, in which case, according to the standard, each field is assigned a unique but unpredictable name.

Examples arising as we go along will make this issue a little clearer. I shall use the term anonymous column to refer to a column whose name is unpredictable and therefore effectively undefined. Note carefully that if the word ROW is omitted and the row consists of a single field, then the parentheses can also be omitted. Thus, VALUES 'S1' denotes a table consisting of a single column and a single row, the SQL counterpart of RELATION { TUPLE { StudentId 'S1' } } (though the SQL counterpart has nothing corresponding to the attribute name).

Request for Solution File

Ask an Expert for Answer!!
PL-SQL Programming: example of table literal - sqlexample a table
Reference No:- TGS0180810

Expected delivery within 24 Hours