How to query the number of tables, custom functions, stored procedures, and views in Oracle database

To view the number of tables, stored procedures, views, and custom functions owned by a specific user in an Oracle database, you can use the following SQL query. The table starting with all_ can be replaced with dba_tables according to your actual situation.

### Check the number of tables:

```sql
SELECT COUNT(*) 
FROM all_tables 
WHERE owner = 'USERNAME';
```
Here, replace `'USERNAME'` with the user name you want to query.

### Check the number of stored procedures:

```sql
SELECT COUNT(*) 
FROM all_procedures 
WHERE owner = 'USERNAME' AND object_type = 'PROCEDURE';
```
Here, replace `'USERNAME'` with the user name you want to query.

### Check the number of views:

```sql
SELECT COUNT(*) 
FROM all_views 
WHERE owner = 'USERNAME';
```
Here, replace `'USERNAME'` with the user name you want to query.

### Check the number of custom functions:

```sql
SELECT COUNT(*) 
FROM all_procedures 
WHERE owner = 'USERNAME' AND object_type = 'FUNCTION';
```
Here, replace `'USERNAME'` with the user name you want to query.

Note that these queries must be run under a user with sufficient permissions so that all users' objects can be viewed.

Guess you like

Origin blog.csdn.net/u013933709/article/details/131673378