Useful sql commands
Start a new database instance:
pg_ctl init -d TEST
pg_ctl -D TEST -o "-p 5433" start
Connect to the new database instance
psql -p 5433
Check username and current database:
select current_user;
select current_database();
Create and connect to a database:
create database test;
\c test;
Create the schema for our tables:
create schema fSchema;
Create table in fSchema:
create table fSchema.mmse (patientID integer, visitID integer, MMSE integer);
List data in a table:
select * from fSchema.mmse;
Insert data into a table:
insert into fSchema.mms (patientID,visitID,MMSE)
values
(1,1,30),
(1,2,25),
(2,1,30),
(2,2,30);
For text variables:
insert into fschema.iselect (variableName,visitID)
values
('MMSE',2),('ADPD',1);