Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way to list columns in Postgres #153

Open
Jaymon opened this issue Jan 18, 2023 · 2 comments
Open

Better way to list columns in Postgres #153

Jaymon opened this issue Jan 18, 2023 · 2 comments

Comments

@Jaymon
Copy link
Owner

Jaymon commented Jan 18, 2023

via

SELECT column_name FROM information_schema.columns where table_name = '<TABLE NAME>'

This seems way better than the horrible query I'm using right now

Search

  • postgres 12.8 get fields of table
@Jaymon
Copy link
Owner Author

Jaymon commented Mar 21, 2023

Looks like information_schema.columns doesn't give primary key information. I could combine the output of information_schema.columns with information_schema.table_constraints to make this work but I'm not sure it's worth it.

This is the postgres wiki solution on getting primary key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant