SqlDataInspector
SqlDataInspector copied to clipboard
Support for Postgres
Hi Devs,
It would be awesome if support for Postgres is added.
Thank you
Hi @Aklil the support for Postgres is not that simple now. I see that there is a dedicated extension for connecting to Postgres databases, so I need to investigate on this topic.
The analysis of the extension below can be useful for the implementation of this feature: https://github.com/microsoft/azuredatastudio-postgresql
Queries for retrieving metadata about schemas, tables and columns.
-- Get the list of schemas
select * from information_schema.schemata where schema_owner = 'pg_database_owner';
-- Get the list of tables
select * from information_schema.tables where table_schema = 'public';
-- Get the list of columns
select * from information_schema.columns where table_schema = 'public' and table_name = 'test';
-- Get the list of table columns with their data types and primary keys
select
c.ordinal_position,
c.column_name,
c.udt_name,
character_maximum_length,
is_nullable,
case when kcu.column_name is not null then 'yes' else 'no' end as is_primary_key
from
information_schema.columns as c
left join (
select
kcu.column_name,
kcu.ordinal_position
from
information_schema.table_constraints as tc
join information_schema.key_column_usage as kcu
on tc.constraint_name = kcu.constraint_name
where
tc.constraint_type = 'PRIMARY KEY'
and tc.table_schema = 'public'
and tc.table_name = 'test'
) as kcu
on c.column_name = kcu.column_name
where
c.table_schema = 'public'
and c.table_name = 'test';
Feature implemented in version 0.8.0.