Tuesday, June 30, 2009
Char or Varchar in oracle
Monday, June 22, 2009
Comparing Two Tables: Highlighting the Differences
I was looking for this for long time about two weeks. At last I got this. But the bad luck is really bad. I cant understand this. May be helpful for you
Sunday, March 15, 2009
Creating table from another table...
Its about creating table in ORACLE. Surely how to create a table is not an issue here.
I was trying to create a table from another table with this query.
create table table_2 as (select * from table_1);
This will work fine. It will create a table and copy all data from table 1 to table 2. This may not be desired everywhere. Sometimes you may need and empty table with the same schema. That is also possible in this way. Just add a where clause which selects no values. Like the following
create table table_2 as (select * from table_1 where table_1.fiels_1 = ‘la bla bla’);
I was facing a different problem. The originating table has primary key and few foreign keys. These were not being incorporated to the new table. This is very much obvious because most of the keys have data dependency. So if oracle wants to put the constraints on the new table, it will take a lot of time to create the new table due to a brut force data analysis.
So during creating table keep this in mind that the constraints will not be incorporated in this way.
Saturday, January 31, 2009
Parameter naming problem in oracle function & Procedure..
Suppose the function has a parameter named employee_ID and you are working on a table where a column name is also employee_ID. And now suppose you have a query like this in your function.
select employee_name from employee_table where employee_id = employee_id;
Your intension may be to compare the column of the table to the parameter. Ok lets make it more clear to Oracle. Suppose your query is like the following now
select employee_name from employee_table et where et.employee_id = employee_id;
Still no way. You may be expecting only one row but you will get all the rows of your table. this query in fact will work just like following
select employee_name from employee_table et where et.employee_id = et.employee_id;
So here it is clear why you will get all the rows.
So what I want to say here is, It is always safe to use different name for parameters like param_employee_id so that oracle cant be confused with other names used in your tables.
Just select the new diagram window. Now select the the tables you want to put in your ERD, then just drag them onto the digram space. You will get the view with all of your tables relation and key constrains. Most interesting is this you can do about all sorts of DB operation from this diagram. Just click right to get more information.
insert into table1 values ('data1', 'data2')
always mention the field name for which you are inserting values
insert into table1 (field1, field2) values ('data1', 'data2')
This way it is ensured that whatever changes you may do on your table, if the columns exists you insert with the old queries.
Within last few days I was stuck with my this mistake and it took a whole night to change all the queries of my application according to the new schema though just a new column has been added..
Wednesday, January 28, 2009
Saturday, September 27, 2008
But it is really simple...
you can just use PL/SQL developer to do this..
If your table contains any CLOB/BLOB type field then just open your table in data editable mode in PL/SQL. and select the Image/ File tab...
and you will get all you need...