Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

What is the default locking mechanism in PostgresSQL when we create a table ? is it row, page, table level or something else?

Is it possible to specify row level locking when we create a table ? something like below in Sybase.

CREATE TABLE user 
(...)
LOCK DATRAROWS  

Or do we not need to specify any locking strategy and leave it to Postgres to choose the best while we dealing CRUD ?

Cheers!

share|improve this question
1  
I believe postgres always uses the least intrusive locking mechanism possible -- MVCC row level locking, in most cases. –  Frank Farmer Apr 30 '11 at 0:29
    
Why would you need to do that? –  Peter Eisentraut Apr 30 '11 at 6:37
    
I'm coming from Sybase space, where we used to explicitly set lock datarows, and here in my specific use case, I don't want Postgres to use anything other than row level locking. Now I understand things are bit different in PGSql :-) –  sojin May 1 '11 at 14:28

2 Answers 2

up vote 1 down vote accepted

There isn't anything you can specify at CREATE TABLE time for PostgreSQL. At run time, you can select rows FOR UPDATE or FOR SHARE. If you're coming to PostgreSQL from another platform, you should skim the docs on concurrency control.

share|improve this answer

There is no locking when you create a table. Locking can be read here: http://www.postgresql.org/docs/9.0/static/explicit-locking.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.