Changeset: 3002f5799af1 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3002f5799af1 Added Files: sql/scripts/52_describe.sql Branch: monetdbe-proxy Log Message:
Copy 'describe' SQL script from mtest. diffs (48 lines): diff --git a/sql/scripts/52_describe.sql b/sql/scripts/52_describe.sql new file mode 100644 --- /dev/null +++ b/sql/scripts/52_describe.sql @@ -0,0 +1,43 @@ +-- This Source Code Form is subject to the terms of the Mozilla Public +-- License, v. 2.0. If a copy of the MPL was not distributed with this +-- file, You can obtain one at http://mozilla.org/MPL/2.0/. +-- +-- Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V. + +create function describe_table(schemaName string, tableName string) + returns table(name string, query string, type string, id integer, remark string) +BEGIN + RETURN SELECT t.name, t.query, tt.table_type_name, t.id, c.remark + FROM sys.schemas s, sys.table_types tt, sys._tables t + LEFT OUTER JOIN sys.comments c ON t.id = c.id + WHERE s.name = schemaName + AND t.schema_id = s.id + AND t.name = tableName + AND t.type = tt.table_type_id; +END; + +create function describe_columns(schemaName string, tableName string) + returns table(name string, type string, digits integer, scale integer, Nulls boolean, cDefault string, number integer, remark string) +BEGIN + return SELECT c.name, c."type", c.type_digits, c.type_scale, c."null", c."default", c.number, com.remark + FROM sys._tables t, sys.schemas s, sys._columns c + LEFT OUTER JOIN sys.comments com ON c.id = com.id + WHERE c.table_id = t.id + AND t.name = tableName + AND t.schema_id = s.id + AND s.name = schemaName + ORDER BY c.number; +END; + +create function describe_function(schemaName string, functionName string) + returns table(id integer, name string, type string, language string, remark string) +BEGIN + return SELECT f.id, f.name, ft.function_type_keyword, fl.language_keyword, c.remark + FROM sys.functions f + JOIN sys.schemas s ON f.schema_id = s.id + JOIN sys.function_types ft ON f.type = ft.function_type_id + LEFT OUTER JOIN sys.function_languages fl ON f.language = fl.language_id + LEFT OUTER JOIN sys.comments c ON f.id = c.id + WHERE f.name=functionName AND s.name = schemaName; +END; + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list