PostgreSQL Metadata

 
In this overload first parameter is name of a collection, and second parameter is the array of restrictions to be applied when querying information. These restrictions specify which subset of the collection will be returned. The restrictions can include, for example, the database name (in this case, only collection elements belonging to this database will be returned) or the mask for the name of collection elements (only the elements satisfying this mask will be returned). The quantity and description of restrictions allowed for each metadata collection are represented in the table here. Their number can also be obtained from the return of the GetSchema() method. If the second parameter is null/Nothing, it is ignored.
Instead of specifying the metadata collection name as a string constant, you may use members of System.Data.DbMetaDataCollectionNames and Devart.Data.PostgreSql.PgSqlMetadataCollectionNames as the first GetSchema argument values. The members of these classes are the string fields, each field stores the corresponding metadata collection name. It is recommended to use these fields rather than manually input the collection names manually as the string constants because in case of using these fields, you will find misspellings at compile-time, and intellisense will show you all the available metadata collection names.
GetSchema Method Reference
GetSchema supports two kinds of wildcards: "%" and "_". These special characters behave exactly as in LIKE operator. "%" means zero or more of any characters, "_" means any single character.
When calling the GetSchema method, you can pass all or few of restrictions, applicable to the chosen collection. In the latter case, you have to put "%" wildcard in the place of omitted restriction, if it must be specified before the restriction you want to apply. For example, GetSchema("Casts", new string[] { "%", "%", "date" }) returns list of all casts to type "date". Or, suppose you want to query all functions within a certain schema: GetSchema("Functions", new string[] { "%", "public" }) returns list of all functions in schema public. Note that this collection may accept 8 restrictions, however, you do not need to specify all of them.
The following table provides detailed information on metadata collections that can be retrieved using the GetSchema method, and restrictions that can be applied for them. Some collections may be not supported in older server versions. If you try to get metadata for unsupported collection you will get exception with message "Collection not defined".

 

Collection Name
Number of restrictions
Remarks
MetaDataCollections0
Returns this list. Same as using GetSchema() method without parameters.
ReservedWords0
Lists all reserved words used in the server.
AggregateFunctions2
GetSchema("AggregateFunctions") returns detailed list of all aggregate functions on the server.
  • The first restriction for this collection is a name of a function. If specified, the method returns all overloads with given name.
  • The second restriction is name of function definer. For example, you can issue "%" as the first restriction, and "postgres" as the second one, to obtain list of functions defined by user "postgres".

     

Arguments5
GetSchema("AggregateFunctions") returns the list of the function arguments. The following restrictions may be specified:
  • Schema name
  • Function name
  • User name
  • Type
  • Function OID (for overload functions)
Casts3
GetSchema("Casts") returns list of casts available on the server.
  • The first restriction for this collection is namespace of a cast.
  • The second restriction is source type for the cast.
  • The third restriction is target type for the cast.

     

Columns3
Returns list of columns, their schema, table, type, and some extra information.
  • Restricted by schema name, GetSchema returns columns of all tables within the schema.
  • The second restriction is name of a table that GetSchema method should search in.
  • At last, you can set column name pattern to filter columns by name.

     

Databases3
Returns list of databases on the server.
  • The first restriction is a name of a database.
  • The second restriction is definer's name.
  • The last restriction is encoding of the database.

     

DatasourceInformation1
Returns information about data sources.
The only restriction is schema name.
Domains9
Returns list of domains on the server. The restrictions for this collection are the following:
  • Domain name
  • Definer
  • OID type
  • Base type
  • Type length
  • Typmod
  • Number of dimensions
  • Schema name
  • OID

     

ForeignKeys4
Returns list of foreign keys on the server. The restrictions for this collection are the following:
  • Key name
  • Schema name
  • Table name
  • OID

     

Functions8
Returns list of functions on the server. The following restrictions may be specified:
  • Function name
  • Schema name
  • Definer
  • Language
  • Arguments count
  • Return type OID
  • Return type
  • OID

     

Groups1
Lists all groups on the server, including IDs and members.
The only restriction is a group name.
Indexes4
Returns list of indexes and their details. Restricted by:
  • Index name
  • Schema name
  • Table name
  • OID

     

Languages2
Lists all languages on the server.
The first restriction is a language name, the second is OID.
NestedTables5
Lists nested tables on the server. Restricted by:
  • Table name
  • Schema name
  • Parent table name
  • Parent schema name
  • OID

     

Operators2
Returns list of operators allowed on the server.
Restrict it by OID and name.
PrimaryKeys3
Returns list of primary keys on the server.
  • First restriction is key name.
  • Second is schema name
  • Third is table name

     

Schemas2
Returns list of schemas on the server.
  • The first restriction is OID
  • The second restriction is schema name

     

Tables4
Returns list of tables on the server. Restrict the collection with:
  • OID
  • Table name
  • Schema name
  • Definer

     

Triggers6
Returns list of triggers on the server. Restricted by:
  • OID
  • Trigger name
  • Schema name
  • Definer
  • Language
  • Arguments count

     

Types5
Returns list of types on the server. Restricted by:
  • OID
  • Type name
  • Schema name
  • Definer
  • Type Length

     

Users1
Lists all users on the server.
When restricted by username, returns information about specific user.
Views4
Returns list of types on the server. Restricted by:
  • OID
  • View name
  • Schema name
  • Definer

     

Npgsql 集合:

MetaDataCollections
Restrictions
Databases
Tables
Columns
Views
Users

https://github.com/npgsql/Npgsql/releases/tag/v2.2.4.3

http://npgsql.projects.pgfoundry.org/docs/api/Npgsql.NpgsqlConnection.GetSchema_overloads.html

http://www.codeproject.com/Articles/37154/PostgreSQL-PostGis-Operations

数据类型:

bitSystem.Int641560
varbitSystem.Int641560
bit varyingSystem.Int641560
boolSystem.Boolean16
booleanSystem.Boolean16
smallintSystem.Int1621
intSystem.Int3223
integerSystem.Int3223
int4System.Int3223
serialSystem.Int3223
serial4System.Int3223
bigintSystem.Int6420
int8System.Int6420
bigserialSystem.Int6420
serial8System.Int6420
floatSystem.Single700
realSystem.Single700
float4System.Single700
doubleSystem.Double701
double precisionSystem.Double701
decimalSystem.Decimal1700
numericSystem.Decimal1700
decSystem.Decimal1700
dateSystem.DateTime1082
timestampSystem.DateTime1114
timestamptzSystem.DateTime1184
timeSystem.TimeSpan1083
timetzSystem.TimeSpan1266
intervalSystem.TimeSpan1186
charSystem.String1042
characterSystem.String1042
uuidSystem.Guid2950
varcharSystem.String1043
character varyingSystem.String1043
textSystem.String25
binarySystem.Byte[]17
byteaSystem.Byte[]17
cidrSystem.String29
circleSystem.String718
inetSystem.String869
lineSystem.String628
lsegSystem.String601
macaddrSystem.String829
boxSystem.String603
pathSystem.String602
pointSystem.String600
polygonSystem.String604
moneySystem.Double790

 

 集合:

MetaDataCollections
ReservedWords
AggregateFunctions
Arguments
Casts
CompositeTypeAttributes
Columns
DataSourceInformation
DataTypes
Databases
Domains
ForeignKeys
ForeignKeyColumns
Functions
Groups
Indexes
Indexcolumns
Languages
NestedTables
Operators
OperatorClasses
PrimaryKeys
Rules
Schemas
Sequences
Tables
Triggers
Types
Users
UserPrivileges
UniqueKeys
Views
Restrictions
Postgresql  NpgsqlDbType System.DbType Enum .Net System Type ---------- ------------ ------------------ ---------------- int8 Bigint Int64 Int64 bool Boolean Boolean Boolean bytea Bytea Binary Byte[] date Date Date DateTime float8 Double Double Double int4 Integer Int32 Int32 money Money Decimal Decimal numeric Numeric Decimal Decimal float4 Real Single Single int2 Smallint Int16 Int16 text Text String String time Time Time DateTime timetz Time Time DateTime timestamp Timestamp DateTime DateTime timestamptz TimestampTZ DateTime DateTime interval Interval Object TimeSpan varchar Varchar String String inet Inet Object IPAddress bit Bit Boolean Boolean uuid Uuid Guid Guid array Array Object Array
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值