Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Monday, April 16, 2012

Find constraint in Oracle database

When you're developing web applications, you usually persist against a database. And sometimes, that database throws errors at you. One of them can be a foreign key or other constraint violation. If you manage the database yourself, the constraint names are of course very logical and tell you immediately where the problem is. But sometimes the DB management isn't in your hands, and then the constraint key can be some random combination of letters and numbers. Obviously, it's not easy to find the cause of the problem then... unless you know how to search!

You can query all constraints in an Oracle database. Usually, the error you get from the database will be somewhere in your logs, or even displayed on the screen, so you have the name of the constraint that is violated. Once you have that, you can just run this simple query:

select constraint_name, table_name
from all_constraints
WHERE constraint_name = 'Faulted_Constraint_Name';


Now you know which table causes the error, and you can start solving the problem.

Of course, the 'all_constraints' table has more fields than just constraint_name and table_name. To find out what more you can query, just use following command:

desc all_constraints

This will give you a list of all queryable fields.

Wednesday, March 7, 2012

Free Cloud DB

I was looking for a free cloud database for my online applications, and to play around with a bit, and found a few solutions.

One was Oracle. My background is Oracle, and it's by far the best database there is. Unfortunately, their cloud solutions doesn't seem to be quite ready yet. You can register, but don't get a cloud database to play with. Yet... As soon as Oracle cloud is up and running, I'll check it out and make a post about it.

We continued our search then. I figured there wouldn't be any free Oracle cloud database, so I extended my reach to all databases. I stumbled upon Xeround. They seem to provide a free MySQL solution. Which basically is Oracle as well, since they acquired Sun. So I signed up, and created a DB instance. Apparantly, instances up to 10MB are free. There are payed solutions if you want more capacity. But for the stuff I'll be doing, 10MB of data will be more then enough.

The creation of an instance took a few minutes, but once finished, my database was up and running. It comes with a very convenient phpMyAdmin online console to manage the database and execute queries. So far, it looks like a very decent solution. Later on, I'll try to use the database in an application!