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
Post a Comment