postgresql: Set the default schema name (like using or use)
Saturday, May 21st, 2011SET search_path TO myschema;
SET search_path TO myschema;
su - postgres psql #or psql mydb
su - postgres createdb DBTest
Backup: $ pg_dump {source_db} -f {dumpfilename.sql}
Restore: $ psql -d {desintation_db} -f {dumpfilename.sql}
Note: on Mac OS X, the command prompt need to be started from the application folder or from pgAdminIII, and then, type “\!” to switch to command shell, and then, go to /Library/PostgreSQL/8.4/bin to find the psql and pg_dump scripts
How to backup and restore postgresql
Somehow, my Postgresql 8.4.3 failed to start on windows. After some digging around, I found the following in the windows event log:
FATAL: bogus data in lock file "postmaster.pid": ""
Removing the file did the trick (it is located at the root folder of your database store)
@Table(name = "mySchema.user")
@javax.persistence.SequenceGenerator(
name="SEQ_STORE",
allocationSize=1,
sequenceName="mySchema.user_id_seq"
)
public class User {
....
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_STORE")
public Long getId() {
return id;
}
}
$ wget http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-8.4-2.noarch.rpm $ rpm -ivh pgdg-centos-8.4-2.noarch.rpm
yum list | grep postgresql
If you see postgresql from other repositories besides pgdg84, then you need to exclude postgresql from coming from other repositories by following the below instructions excerpted from PostgreSQL How to Yum
Add to the bottom of the section:
exclude=postgresql*
yum install postgresql-server
service postgresql initdb
chkconfig postgresql on
su - postgres createdb DBTest
su - postgres psql DBTest
Root directory: /var/lib/pgsql/
Config file: /var/lib/pgsql/data/postgresql.conf