die Seilerwerks

Chronicling Life, Love, Linux and Oracle database administration.

Posts Tagged ‘sql

ALTER TABLE doesn’t like synonyms

with 2 comments

Something new I found out today. When performing an ALTER TABLE statement (in this case to add a column) in another schema for which you have a synonym (public or private), you must refer to it with the schema qualifier, e.g. HR.EMPLOYEES rather than just EMPLOYEES. It seems the DDL statement doesn’t bother itself with synonyms. Probably a good thing, as DDL is nothing to be taken lightly and it’s best to fully spell out what it is you are mucking about with.

In the example, my user has been granted the ALTER ANY TABLE privilege, as well as SELECT on HR.EMPLOYEES. I’ve made a private synonym in my own schema, also named EMPLOYEES. Let’s see what happens:

SQL> alter table employees add foo number;
alter table employees add foo number
*
ERROR at line 1:
ORA-00942: table or view does not exist

SQL> alter table hr.employees add foo number;

Table altered.

Written by Don Seiler

April 14, 2008 at 3:21 pm

Posted in oracle

Tagged with , ,

Multi-Table Inserts: A Serendipitous Tale

without comments

I was doing a bit of studying last night when the material made a passing reference to Oracle’s INSERT ALL and INSERT FIRST, and then had a review question on it. So this morning I set out to do a bit of learning, and was pleased to find that not only had Pythian’s Babette Turner-Underwood recently written on the subject, but that Andrew followed up on her post with another creative use.

Written by Don Seiler

May 2, 2007 at 10:16 am

Posted in Uncategorized

Tagged with , ,

SQL for the Childrens

without comments

Gary “Igore” Myers, upon hearing the glad tidings of Pete Finnigan’s parental status, has produced a handy (if not a bit cheeky) SQL primer for the kids. Maybe I can teach my 21-year-old brother-in-law some SQL now as well.

Written by Don Seiler

April 15, 2007 at 10:34 am

Posted in Uncategorized

Tagged with ,

Comparison of different SQL implementations

without comments

Another gem found off of the oracle-l list is this page, which offers a nice breakdown of the differences between the various RDBMS implementations (Oracle, Postgres, MySQL, etc.) in terms of their SQL implementations.

Written by Don Seiler

February 1, 2007 at 4:40 pm

Posted in Uncategorized

Tagged with ,

Interpreting Query Plans

without comments

Written by Don Seiler

January 30, 2007 at 3:05 pm

Posted in Uncategorized

Tagged with , ,

How The Oracle Database Processes SQL Statements

without comments

Eddie Awad posted (in June) a nice flowchart of what Oracle does when it processes a SQL statement. Of particular import is the note in step 2 (parsing):

“If a similar SQL statement exists in the shared pool, Oracle skips the parsing step. A SQL statement is parsed once no matter how many times the statement is run. As you can see, parsing does many things and consumes time and resources. You should always aim at minimizing parsing when writing SQL.”

How do you minimize parsing? Bind variables! Now go re-write all of your applications to use them.

Written by Don Seiler

November 28, 2006 at 2:10 pm

Posted in Uncategorized

Tagged with , ,