# Examining the database

### Querying the database type and version

The queries to determine the database version for some popular database types are as follows:

```sql
Database type	Query
Microsoft,MySQL	SELECT @@version
Oracle		SELECT * FROM v$version
PostgreSQL	SELECT version()
```

For example, you could use a UNION attack with the following input: `' UNION SELECT @@version--`

***

### Listing the contents of the database

Most database types (**with the notable exception of Oracle**) have a set of views called the information schema which provide information about the database.

You can query information\_schema.tables to list the tables in the database:

```sql
SELECT * FROM information_schema.tables
```

You can then query information\_schema.columns to list the columns in individual tables:

```sql
SELECT * FROM information_schema.columns WHERE table_name = 'Users'
```

#### Equivalent to information schema on Oracle

On Oracle, you can obtain the same information with slightly different queries.

You can list tables by querying all\_tables:

```sql
SELECT * FROM all_tables
```

And you can list columns by querying all\_tab\_columns:

```sql
SELECT * FROM all_tab_columns WHERE table_name = 'USERS'
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.nomanaziz.me/cybersecurity/penetration-testing/portswigger/sql-injection/examining-the-database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
