I want to store a single row in a configuration table for my application. I would like to enforce that this table can contain only one row.
What is the simplest way to enforce the single row constraint ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You make sure one of the columns can only contain one value, and then make that the primary key (or apply a uniqueness constraint).
I have a number of these tables in various databases, mostly for storing config. It’s a lot nicer knowing that, if the config item should be an int, you’ll only ever read an int from the DB.