Determining version
With SQL:
select version();
select current_setting('server_version_num')
show server_version_num
ON the command line (first determines server version, second client version):
pg_config --version
psql --version
Duplicating table structure
Postgres has a very easy way to clone a table, including its indices, comments etc.:
create table tableCopy (like tableOriginal including all);