The "SELECT COUNT(*) FROM ALL_TABLES WHERE OWNER=UPPER('user name') AND TABLE_NAME=UPPER('table name')" statement can be used in oracle to determine whether the specified table exists. If it returns "0 ” then the table does not exist.
The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.
1. The first sql
select count(*) from user_tables where table_name =upper('表名')
This is to query the currently logged in user Whether the table exists in all tables in . Note that the table name is case-sensitive. If the parameters are not restricted, then the upper
function must be added here.
The effect is as follows:
2. The second sql
SELECT COUNT(*) FROM ALL_TABLES WHERE OWNER = UPPER('用户名') AND TABLE_NAME = UPPER('表名')
Example:
Queryznxd_1
Whether the table exists in the table under this user. For example, if you log in as user znxd_gateway
, and execute the above sql on its query panel, you can query whether a certain table exists under this user znxd_1
.
The effect is as follows:
That is to say, when 0
is returned, it means that the database does not have the table, and 1# is returned ## indicates that the table exists.
Oracle Tutorial"
The above is the detailed content of How does Oracle determine whether a table exists?. For more information, please follow other related articles on the PHP Chinese website!