-
Notifications
You must be signed in to change notification settings - Fork 22
SQL schema
meliao edited this page Sep 12, 2019
·
3 revisions
You can easily get an idea of the SQL schema by connecting to PostgreSQL using psql
(you have to use the user/password specified when starting the Docker image of PostgreSQL):
$ psql -h localhost -p 5432 -U ukbrest ukb
ukbdb=#
If you are running inside a Docker container and don't have psql
installed locally, the above command won't work. But you can easily open a bash shell in the Docker container:
$ docker exec -it pg bash
root@pg:/ $ psql -h localhost -p 5432 -U ukbrest ukb
While logged in, you can print the list of tables/relations:
ukbdb=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------------------------------------+-------+---------
public | all_eids | table | ukbrest
public | bad_related_samples_2nd_higher_and_high_missrate | table | ukbrest
public | bgen_samples | table | ukbrest
public | codings | table | ukbrest
public | datadict | table | ukbrest
public | events | table | ukbrest
public | fields | table | ukbrest
public | phenos | table | ukbrest
public | relatedness | table | ukbrest
public | samplesqc | table | ukbrest
public | ukb_pheno_0_00 | table | ukbrest
public | ukb_pheno_0_01 | table | ukbrest
public | ukb_pheno_0_02 | table | ukbrest
public | ukb_pheno_1_00 | table | ukbrest
public | ukb_pheno_1_01 | table | ukbrest
public | ukb_pheno_2_00 | table | ukbrest
public | ukb_pheno_3_00 | table | ukbrest
public | ukb_pheno_3_01 | table | ukbrest
public | ukb_pheno_3_02 | table | ukbrest
public | ukb_pheno_3_03 | table | ukbrest
public | ukb_pheno_3_04 | table | ukbrest
public | ukb_pheno_3_05 | table | ukbrest
public | ukb_pheno_3_06 | table | ukbrest
public | withdrawls | table | ukbrest
(24 rows)
Or explore the columns of a particular table:
ukbdb=# \d fields
Table "public.fields"
Column | Type | Modifiers
-------------+--------+-----------
column_name | text | not null
table_name | text |
field_id | text | not null
description | text |
coding | bigint |
inst | bigint |
arr | bigint |
type | text | not null
[...]