SQL DUMP function
Shows exactly how a value is stored: datatype code, byte length, and each byte. Run it when two strings look equal and fail to match.
- 類別
- Strings
- Returns
string- In this category
- 81 of 172
語法
DUMP(value [, return_format])
引擎支援
| 引擎 | Support | 備註 |
|---|---|---|
| SQL Server | Not built in | No built-in equivalent. |
| PostgreSQL | Not built in | No built-in equivalent. |
| MySQL | Not built in | No built-in equivalent. |
| SQLite | Not built in | No built-in equivalent. |
| Oracle | 是 | Supported under this name. |
範例
Oracle
SELECT DUMP('café') FROM dual;
-- Typ=96 Len=5: 99,97,102,195,169
Oracle
SELECT DUMP(note, 16) FROM notes WHERE id = 1; -- hex bytes
小知識
- Output shape: Typ=96 Len=5: 99,97,102,195,169. A CHAR value (literals are type 96; a VARCHAR2 column shows Typ=1), five bytes, the UTF-8 bytes of 'café' with é as two bytes.
- return_format picks the base: 10 decimal (default), 16 hex, 8 octal, 17 single characters; DUMP(s, 16) for hex inspection.
- It reveals invisible characters: trailing spaces, NBSPs (160), zero-width joiners and CR characters all appear as their byte values.
- Oracle-only. Elsewhere: PostgreSQL's encode(convert_to(s, 'utf8'), 'hex'), MySQL's HEX, SQL Server's CONVERT to varbinary.
Questions about DUMP
Why do two strings that look equal fail to match?
DUMP shows the difference: trailing spaces, NBSP (byte 160), combining accents or different encodings. The byte list is the evidence.
What does Typ=96 mean?
The internal datatype code: 96 is CHAR (string literals are CHAR), 1 is VARCHAR2, 2 is NUMBER, 12 is DATE. It confirms what the column actually stores versus what the client renders.
How do I get hex output from DUMP?
Pass 16 as the return format: DUMP(s, 16). 10 is decimal, 8 octal, 17 prints printable characters.
Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.
Related on SQLly
Cheat sheets for the engines that have it: Oracle.
Functions your engine actually has
SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.