> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/misc/databases/sql-databases/oracle.md).

# Oracle

## Enumeration

### Current version

To get the current version

```sql
select * from v$version;
```

### Current user

To get the current user

```sql
select user from dual;
```

{% hint style="info" %}
NOTE

Oracle database requires a FROM clause with any SELECT statement.

Oracle databases always include a table named [*DUAL*](https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries009.htm)*.* This table has one column named "DUMMY" and one row with value "X". When working with an Oracle database, and we need to select static values or data from functions, we can include from DUAL to create a syntactically-valid query.
{% endhint %}

### Enumerate database owners

To enumerate all users that owns a database table

```sql
select owner from all_tables group by owner;
```

### Enumerate tables by owner

To enumerate tables owned by a specific user

```sql
select table_name from all_tables where owner = '<db_owner>' order by table_name;
```

{% hint style="info" %}
NOTE

Query must include 'sys' as part of the table name. For example, 'sys.menu'.
{% endhint %}

### List columns

To list the columns of a specific database table

```sql
select column_name, data_type from all_tab_columns where table_name = '<db_table>';
```

## Resources

Oracle Database - Hackviser: <https://hackviser.com/tactics/pentesting/services/oracle>

Oracle Database - Wikipedia: <https://en.wikipedia.org/wiki/Oracle_Database>
