> 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/determining-database-type.md).

# Determining Database Type

## Via Version Info

Used query:

```sql
select version();
```

### MySQL

The answer for `select version();` in MySQL databases shows the version number only such as

```
5.7.35
```

### PostgreSQL

The answer for `select version();` in PostgreSQL databases shows detailed information such as

```
PostgreSQL 13.4 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit
```

## Via Database Tables

Used query:

```sql
SELECT table_name FROM information_schema.tables;
```

### MS SQL Server

Microsoft SQL Server contains database tables with names beginning with `spt_` such as

```
spt_fallback_db
spt_fallback_dev
spt_fallback_usg
spt_values
spt_monitor
```

as well as a table called `MSreplication_options`.

### MySQL

MySQL contains a **large** number of database tables such as

```
CHARACTER_SETS
PLUGINS
PROCESSLIST
TABLE_PRIVILEGES
VIEWS
INNODB_LOCKS
INNODB_TRX
INNODB_SYS_DATAFILES
INNODB_FT_CONFIG
INNODB_SYS_VIRTUAL
help_category
help_keyword
help_relation
help_topic
innodb_index_stats
innodb_table_stats
ndb_binlog_index
slave_master_info
slave_relay_log_info
slave_worker_info
events_stages_current
events_stages_history
events_stages_history_long
events_statements_current
events_statements_history
global_status
global_variables
host_cache
hosts
setup_actors
setup_consumers
setup_instruments
host_summary
host_summary_by_file_io
host_summary_by_file_io_type
x$host_summary
x$host_summary_by_file_io
x$host_summary_by_file_io_type
x$host_summary_by_stages
x$schema_index_statistics
x$schema_table_lock_waits
x$schema_table_statistics
```

### PostgreSQL

PostgreSQL contains database tables with names beginning with `pg_` such as:

```
pg_statistic
pg_type
pg_foreign_table
pg_authid
pg_shadow
pg_statistic_ext_data
pg_roles
pg_settings
pg_file_settings
pg_hba_file_rules
pg_config
```
