Skip to main content

Database usage in development and testing environment


In development environment we have access to the database in the read and write mode, where we can play with tables. Instead of writing simple queries to update any tuple, we use for update functionality of the PL/SQL. But it is a bad idea, since we are blocking other users who are operating on the same table, since for update table the lock on the full table, and noone is allowed to perform any operation untill the lock is released.

select * from table_name for update;

Instead of the above query write a simple update query.

update table_name set column_to_set = value_to_set
where column_where_condition = value_where_condition;

This is better idea to practice, or you can simple create a query as mentioned below :

update &table_name set &to_set_column_name = &value_to_set_column_name
where &where_column_name = &value_where_column_name;


This will help the user to input all the details at runtime.

But still in the testing environment, when the developers don't have access to the tables. They are not able to describe the table in the traditional way. so, they can use some other queries which are provided by oracle.

Say, for instance, if you want to describe a table, you can use the following query :

SELECT
column_name "Name",
nullable "Null?",
concat(concat(concat(data_type,'('),data_length),')') "Type"
FROM user_tab_columns
WHERE table_name='TABLE_NAME';

Here, TABLE_NAME is case sensetive and always in caps.

Other table queries are also available, like :

SELECT *
FROM user_col_comments
WHERE table_name='TABLE_NAME';

Comments

Popular posts from this blog

Bitmap index

Bitmap index is one of the index types that is supported by oracle. Unlike B*tree index, this is very compressed index. It means if I create a bitmap index on a column, then the generated index table will be smaller when compared the index table which is generated by the binary index on the same column. The reason is, in bitmap index, ROWIDs won’t be stored in the index table, instead index values will be mapped against bitmaps. Bitmap is nothing but it stores either of this values, 1(Match) or 0(No Match). For each distinct values in the column, a separate index record will be created. Unlike b*tree index, bitmap index can accept NULL and it creates separate index entry for this. Bitmap index will work better if number of distinct values are relatively less when compared to the total number of records. Why is it referred as “relatively less”? this index will work fine if table of 1,000,000,000 records contains 5000 distinct values and if table of 1,000 records contains 5 distinct va...

Hash Natural Join

To perform hash join, Oracle follows these steps: 1.      Oracle chooses the smallest of two tables as the hash table (otherwise called as driving table). Oracle built the hash table in RAM after applying the hash function on the joining column(s) of the driving table. 2.      Oracle chooses the other [big] table as the probe table (otherwise called as driven table or probing table). It traverse through all the records of this probe table, applies the same hash function on the joining column(s) [column(s) used to join these two tables] and will hit the corresponding entry in the hash table. 3.      Oracle returns the output if a record from driving table is already present in the same hash key, else no record will be returned. It may look like Nested loop join & Hash join have the same architecture since both these have the concept of driving & driven tables but they have entirely different design if you closely look a...

Index Range Scan

Index Range Scan is one of the index access methods supported by Oracle. Index Range Scan means the retrieval of one or more ROWIDs from an index. Indexed values are generally scanned in ascending order. Index Range Scan is applicable to both B*Tree Unique Index and B*Tree Non-Unique Index unlike Index Unique Scan, where it is applicable only to B*Tree Unique Index. LITTLE-KNOWN FACTS TO BE REMEMBERED: ·          If Oracle has to follow Index Range Scan, if B*Tree Unique index is created on the table, then in the SQL, any non-equality operator must be used like <=, <, >, >=, IN, BETWEEN. If any of these operators is used, it means more than one index record is going to be referred in the index table and in turn which returns more than one ROWID (because in the unique index, single index value is mapped to single ROWID. So if 5 index records are accessed, it means 5 ROWIDs are retrieved). It is explained in EXAMPLE section. ·  ...