Home > Database > Oracle > How does Oracle determine whether a table exists?

How does Oracle determine whether a table exists?

青灯夜游
Release: 2022-01-13 11:37:16
Original
16537 people have browsed it

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.

How does Oracle determine whether a table exists?

The operating environment of this tutorial: Windows 7 system, Oracle 11g version, Dell G3 computer.

Oracle database determines whether a table exists

1. The first sql

select count(*) from user_tables where table_name =upper('表名')
Copy after login

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:

How does Oracle determine whether a table exists?

2. The second sql

SELECT COUNT(*) FROM ALL_TABLES WHERE OWNER = UPPER('用户名') 
AND TABLE_NAME = UPPER('表名')
Copy after login

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:

How does Oracle determine whether a table exists?

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.

Recommended tutorial: "

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template