To express a byte array constant, see the section on byte array literals for more details. For example, the following three are equivalent literals for the same byte array: b'abc', b'\141\142\143', b'\x61\x62\x63'.In addition to this syntax, CockroachDB also supports using string literals, including the syntax '...', e'...' and x'....' in contexts where a byte array is otherwise expected.
The size of a BYTES value is variable, but it’s recommended to keep values under 1 MB to ensure adequate performance. Above that threshold, write amplification and other considerations may cause significant performance degradation.We strongly recommend adding size limits to all indexed columns, which includes columns in primary keys.Values exceeding 1 MiB can lead to storage layer write amplification and cause significant performance degradation or even crashes due to OOMs (out of memory errors).To add a size limit using CREATE TABLE:
CREATE TABLE name (first STRING(100), last STRING(100));
SET enable_experimental_alter_column_type_general = true;
ALTER TABLE name ALTER first TYPE STRING(99);
If your application requires large binary input in single queries, you can store the blobs somewhere your client can access them (using a cloud storage service, for example), and then reference their addresses from a statement.
BYTES values can be cast explicitly to STRING. This conversion always succeeds. Two conversion modes are supported, controlled by the session variablebytea_output:
hex (default): The output of the conversion starts with the two characters \, x and the rest of the string is composed by the hexadecimal encoding of each byte in the input. For example, x'48AA'::STRING produces '\x48AA'.
escape: The output of the conversion contains each byte in the input, as-is if it is an ASCII character, or encoded using the octal escape format \NNN otherwise. For example, x'48AA'::STRING produces '0\252'.
STRING values can be cast explicitly to BYTES. This conversion will fail if the hexadecimal digits are not valid, or if there is an odd number of them. Two conversion modes are supported:
If the string starts with the two special characters \ and x (e.g., \xAABB), the rest of the string is interpreted as a sequence of hexadecimal digits. The string is then converted to a byte array where each pair of hexadecimal digits is converted to one byte.
Otherwise, the string is converted to a byte array that contains its UTF-8 encoding.
While both STRING and BYTES can appear to have similar behavior in many situations, one should understand their nuance before casting one into the other.STRING treats all of its data as characters, or more specifically, Unicode code points. BYTES treats all of its data as a byte string. This difference in implementation can lead to dramatically different behavior. For example, let’s take a complex Unicode character such as ☃ (the snowman emoji):
> SELECT length('☃'::string);
length+--------+ 1
> SELECT length('☃'::bytes);
length+--------+ 3
In this case, LENGTH(string) measures the number of Unicode code points present in the string, whereas LENGTH(bytes) measures the number of bytes required to store that value. Each character (or Unicode code point) can be encoded using multiple bytes, hence the difference in output between the two.
A literal entered through a SQL client will be translated into a different value based on the type:
BYTES give a special meaning to the pair \x at the beginning, and translates the rest by substituting pairs of hexadecimal digits to a single byte. For example, \xff is equivalent to a single byte with the value of 255. For more information, see SQL Constants: String literals with character escapes.
STRING does not give a special meaning to \x, so all characters are treated as distinct Unicode code points. For example, \xff is treated as a STRING with length 4 ( \, x, f, and f ).
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"CockroachDB","colors":{"primary":"#9059FF","light":"#9059FF","dark":"#9059FF"},"logo":{"light":"https://mintcdn.com/cockroachlabs/4WvUnbVuGZfqM4kW/images/CockroachLabs_Wordmark_Black.png?fit=max\u0026auto=format\u0026n=4WvUnbVuGZfqM4kW\u0026q=85\u0026s=54ccae625c9986bf1df8ddc7b2c571f0","dark":"https://mintcdn.com/cockroachlabs/4WvUnbVuGZfqM4kW/images/CockroachLabs_Wordmark_White.png?fit=max\u0026auto=format\u0026n=4WvUnbVuGZfqM4kW\u0026q=85\u0026s=0dd9b66973a1c7d3dd72aa67b6094efe","href":"https://www.cockroachlabs.com/"},"favicon":{"light":"https://mintcdn.com/cockroachlabs/2yihO7vMXnL0G_07/images/favicon.svg?fit=max\u0026auto=format\u0026n=2yihO7vMXnL0G_07\u0026q=85\u0026s=01f9aa59c9f275e1f35cd424a27d2551","dark":"https://mintcdn.com/cockroachlabs/2yihO7vMXnL0G_07/images/favicon.svg?fit=max\u0026auto=format\u0026n=2yihO7vMXnL0G_07\u0026q=85\u0026s=01f9aa59c9f275e1f35cd424a27d2551"},"api":{"examples":{"defaults":"required","languages":["curl"]}},"appearance":{"default":"light"},"navbar":{"primary":{"type":"button","label":"Get started free","href":"https://cockroachlabs.cloud/signup?referralId=cc_nav_global\u0026_ga=2.242886210.1147139380.1759903632-41552699.1759903632"}},"footer":{"socials":{"youtube":"https://www.youtube.com/@cockroachdb","x":"https://x.com/CockroachDB","linkedin":"https://www.linkedin.com/company/cockroach-labs/mycompany/verification","instagram":"https://www.instagram.com/cockroachdb"},"links":[{"header":"Product","items":[{"label":"CockroachDB","href":"https://www.cockroachlabs.com/product"},{"label":"CockroachDB Cloud","href":"https://www.cockroachlabs.com/product/cockroachcloud"},{"label":"Compare","href":"https://www.cockroachlabs.com/compare"},{"label":"Pricing","href":"https://www.cockroachlabs.com/pricing"},{"label":"Get CockroachDB","href":"https://www.cockroachlabs.com/get-started-cockroachdb"},{"label":"Sign In","href":"https://cockroachlabs.cloud/"}]},{"header":"Resources","items":[{"label":"Guides","href":"https://resources.cockroachlabs.com/guides"},{"label":"Webinars","href":"https://www.cockroachlabs.com/community/webinars"},{"label":"Videos","href":"https://www.cockroachlabs.com/resources/video"},{"label":"Architecture Overview","href":"https://www.cockroachlabs.com/docs/stable/architecture/overview"},{"label":"FAQ","href":"https://www.cockroachlabs.com/docs/stable/frequently-asked-questions"},{"label":"Security","href":"https://www.cockroachlabs.com/security"}]},{"header":"Learn \u0026 Support","items":[{"label":"Docs","href":"https://www.cockroachlabs.com/docs"},{"label":"University","href":"https://learn.cockroachlabs.com/"},{"label":"Developers","href":"https://www.cockroachlabs.com/developers"},{"label":"Forum","href":"https://forum.cockroachlabs.com/"},{"label":"Slack","href":"https://cockroa.ch/slack"},{"label":"Support Portal","href":"https://support.cockroachlabs.com/hc/en-us"},{"label":"Contact Us","href":"https://www.cockroachlabs.com/contact"}]},{"header":"Company","items":[{"label":"About","href":"https://www.cockroachlabs.com/about"},{"label":"Blog","href":"https://www.cockroachlabs.com/blog"},{"label":"Careers","href":"https://www.cockroachlabs.com/careers"},{"label":"Customers","href":"https://www.cockroachlabs.com/customers"},{"label":"News","href":"https://www.cockroachlabs.com/press"},{"label":"Privacy","href":"https://www.cockroachlabs.com/privacy"},{"label":"Terms of Use","href":"https://www.cockroachlabs.com/website-terms-of-use"}]}]},"fonts":{"heading":{"family":"Poppins"},"body":{"family":"Open Sans"}},"styling":{"eyebrows":"breadcrumbs","codeblocks":{"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}},"latex":true},"integrations":{"gtm":{"tagId":"GTM-NR8LC4"}},"errors":{"404":{"redirect":false,"title":"Page not found","description":"The page you're looking for doesn't exist. [Return to docs home](/index.html)."}},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"interaction":{"drilldown":false},"navigation":{"global":{"anchors":[{"anchor":"University","icon":"graduation-cap","href":"https://learn.cockroachlabs.com/"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"cockroachlabs","hasAudioNarration":false,"actualSubdomain":"cockroachlabs","customDomains":["docs.cockroachlabs.com"],"gitSource":{"type":"github","owner":"cockroachlabs","repo":"docs","deployBranch":"main","contentDirectory":"cockroachlabs-preview-main","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af4bb21d7a808c67a4ac795","clientVersion":"0.0.4111","searchFilterCounts":[{"language":"default","tag":"CockroachDB","count":6951},{"language":"default","tag":"Docs","count":3217},{"language":"default","tag":"SQL","count":2566},{"language":"default","tag":"Statements","count":1714},{"language":"default","tag":"Self-Hosted Deployments","count":1457},{"language":"default","tag":"Reference","count":774},{"language":"default","tag":"Cloud Deployments","count":616},{"language":"default","tag":"Endpoints","count":528},{"language":"default","tag":"Cloud API Reference","count":518},{"language":"default","tag":"Get Started","count":441}],"searchSettings":{"isFiltersEnabled":true,"showContentSnippets":true,"fullPageSearch":true}},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":true},"customCss":[{"filePath":"styles.css","content":":root{--inline-code-bg-light: rgb(var(--gray-200) / 0.92);--inline-code-bg-dark: rgb(255 255 255 / 0.08)}.prose :not(pre)>code{background-color:var(--inline-code-bg-light)!important}.dark .prose :not(pre)>code{background-color:var(--inline-code-bg-dark)!important}@media (min-width: 1536px){#navbar>.max-w-8xl,[class*=\"peer-[.is-not-custom]:peer-[.is-not-center]:max-w-8xl\"]{width:100%!important;max-width:none!important}}#navigation-items{display:flex;flex-direction:column}#navigation-items>ul:not(.sidebar-group){order:1;margin-top:1.5rem}.crdb-metrics-table table{table-layout:fixed!important;width:100%!important;min-width:0!important;max-width:100%!important;border-collapse:collapse}.crdb-metrics-table table td,.crdb-metrics-table table th{min-width:0!important;overflow-wrap:anywhere;word-break:break-word}.crdb-fixed-table table{table-layout:fixed!important;width:100%!important;min-width:0!important;max-width:100%!important;border-collapse:collapse}.crdb-fixed-table table td,.crdb-fixed-table table th{min-width:0!important;overflow-wrap:anywhere;word-break:break-word}.bg-cover{background-size:cover;background-repeat:no-repeat;background-position:center center}.bg-cover__bg-3-1{background-image:url(\"https://cockroach-labs-docs.imgix.net/bg-3-1.png?auto=format,compress\u0026w=1200\u0026q=40\")}.home-header{border-radius:0.5rem;margin-bottom:2rem!important;padding:2rem}.card{border:1px solid #e5e7eb;border-radius:0.75rem;background-color:white}.dark .card{background-color:#0d1117;border-color:rgba(255, 255, 255, 0.1)}.card-link{text-decoration:none!important;overflow:hidden}.card-link:hover{outline:1px solid rgba(105, 51, 255, 0.55);outline-offset:-1px}.card-link,.card-link:hover{transform:none!important;box-shadow:none!important}.card-link a,.card-link a:hover,.card-link h3,.card-link h3:hover,.card-link p,.card-link p:hover{border:0!important;text-decoration:none!important;transform:none!important}.card-link a{display:block;width:100%}.card-link h3{font-size:1rem!important;font-weight:600!important}.card-body{padding:1.5rem}.landing-column-title{margin-bottom:1rem}.overline{text-transform:uppercase;letter-spacing:0.05em}.btn-redirect{display:inline-flex;align-items:center;gap:0.5rem;padding:0.75rem 1.5rem;border:2px solid #e5e7eb;border-radius:0.5rem;text-decoration:none;transition:border-color 0.2s}.btn-redirect:hover{border-color:#6933ff}.btn-block{display:flex;width:100%;justify-content:center}.dark .btn-redirect{border-color:rgba(255, 255, 255, 0.1)}.article-section-title{font-size:1.25rem!important}.article-lists h3{font-size:0.875rem!important;font-weight:600!important;text-transform:uppercase;letter-spacing:0.05em;color:#6b7280!important}.dark .article-lists h3{color:#9ca3af!important}.article-lists ul{font-size:0.875rem}.shadow{box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15)}.bg-dark-wing{background-color:#152849;border-radius:0.5rem}.text-ice-temple{color:#1bf8ec!important;display:inline-flex;align-items:center;gap:0.375rem}.text-ice-temple img{display:inline-block;margin:0}.bg-dark-wing h2{font-size:clamp(1.25rem, 1rem + 1.5vw, 1.75rem)!important}@media (max-width: 576px){.card-body.bg-dark-wing{padding:1.25rem!important}}.text-decoration-none{text-decoration:none!important}.text-muted{color:#6b7280!important}.card-link .card-desc{font-size:0.9375rem!important;font-weight:400!important;line-height:1.5!important;text-align:left!important;color:#4b5563!important;width:100%;margin-top:0.5rem}.dark .card-link .card-desc{color:#9ca3af!important}.report-tag{display:inline-block;padding:0.25rem 0.75rem;border-radius:0.25rem;background-color:rgba(84, 42, 189, 0.08);color:#542abd}.dark .report-tag{background-color:rgba(84, 42, 189, 0.3);color:#b39dff}.resilience-report-img{background-image:url(\"/images/state-resilience.png\");background-size:cover;background-position:center;min-height:150px;border-radius:0.5rem}.row{display:flex!important;flex-wrap:wrap;margin-left:-0.75rem;margin-right:-0.75rem}.display-flex{display:flex!important}.col-lg-4{flex:0 0 auto;width:100%;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 992px){.col-lg-4{width:33.333333%!important}}.col-lg-3,.col-sm-6,.col-xs-12{flex:0 0 auto;width:100%!important;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 992px){.col-lg-3{width:25%!important}}@media (min-width: 576px){.col-sm-6{width:50%!important}}.col-12{width:100%!important}.col-lg-12{width:100%;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 992px){.col-lg-12{width:100%!important}}.col-md-4,.col-md-8{flex:0 0 auto;width:100%;padding-left:0.75rem;padding-right:0.75rem}@media (min-width: 768px){.col-md-4{width:33.333333%!important}.col-md-8{width:66.666667%!important}}.h-100{height:100%}.d-flex{display:flex}.flex-column{flex-direction:column}.mb-3{margin-bottom:1rem!important}.mb-5{margin-bottom:3rem!important}.pb-5{padding-bottom:3rem!important}.mb-xl-5{margin-bottom:3rem!important}.mt-auto{margin-top:auto!important}.mt-0{margin-top:0!important}.mt-2{margin-top:0.5rem!important}.mt-3{margin-top:1rem!important}.mt-5:not(.code-block){margin-top:3rem!important}.code-block.mb-8{margin-bottom:calc(var(--spacing) * 5)}.pt-5{padding-top:3rem!important}.m-0{margin:0!important}.ml-2{margin-left:0.5rem!important}.mb-0{margin-bottom:0!important}.mb-2{margin-bottom:0.5rem!important}.mb-4{margin-bottom:1.5rem!important}.p-2{padding:0.5rem!important}.p-3{padding:1rem!important}.p-4{padding:1.5rem!important}.pb-3{padding-bottom:1rem!important}.pb-4{padding-bottom:1.5rem!important}.ml-1{margin-left:0.25rem!important}.mr-auto{margin-right:auto!important}.justify-content-center{justify-content:center!important}.align-items-center{align-items:center!important}@media (min-width: 1200px){.p-xl-5{padding:3rem!important}}.mx-0{margin-left:0!important;margin-right:0!important}.text-center{text-align:center}.text-white{color:white!important}.text-black{color:black!important}.dark .text-black{color:white!important}.container{width:100%;max-width:1200px;margin-left:auto;margin-right:auto;padding-left:1rem;padding-right:1rem}.card-header-overlap-text{position:relative}@media (min-width: 768px){.p-md-5{padding:3rem!important}}@media (min-width: 992px){.d-lg-flex{display:flex!important}.mb-lg-0{margin-bottom:0!important}}.prose table{border-collapse:collapse!important}.prose table th,.prose table td{border:1px solid rgb(var(--gray-200))!important}.dark .prose table th,.dark .prose table td{border-color:rgb(var(--gray-700) / 0.5)!important}.prose table th{padding:0.571429em;font-weight:600;vertical-align:bottom;color:var(--tw-prose-headings);text-align:left}.prose table th.center-align{text-align:center}.prose table td{padding:0.571429em;vertical-align:baseline}[data-component-part=\"accordion-description\"]{font-size:0.875rem!important}.accordion.mb-3{margin-bottom:0.25rem!important}@media (max-width: 991.98px){[id^=\"kapa-widget-container\"] button{width:36px!important;height:36px!important;min-width:36px!important;padding:0!important;font-size:0!important}[id^=\"kapa-widget-container\"] button svg{width:18px!important;height:18px!important}[id^=\"kapa-widget-container\"] button span{display:none!important}}table.crdb-fixed-table{table-layout:fixed!important;min-width:0!important;width:100%}table.crdb-fixed-table td,table.crdb-fixed-table th{min-width:0!important;overflow-wrap:break-word;word-break:normal}.sql-grammar svg .line{fill:none;stroke:#262626}.sql-grammar svg .bold-line{stroke:#0A0A0A;shape-rendering:crispEdges;stroke-width:2}.sql-grammar svg .thin-line{stroke:#0F0F0F;shape-rendering:crispEdges}.sql-grammar svg .filled{fill:#262626;stroke:none}.sql-grammar svg text.terminal{font-family:Verdana, Sans-serif;font-size:12px;fill:#0A0A0A;font-weight:bold}.sql-grammar svg text.nonterminal{font-family:Verdana, Sans-serif;font-size:12px;fill:#0055FF}.sql-grammar svg text.regexp{font-family:Verdana, Sans-serif;font-size:12px;fill:#0F0F0F}.sql-grammar svg rect,.sql-grammar svg circle,.sql-grammar svg polygon{fill:#262626;stroke:#262626}.sql-grammar svg rect.terminal{fill:#ffffff;stroke:#262626}.sql-grammar svg rect.nonterminal{fill:#FFFFFF;stroke:#262626}.sql-grammar svg rect.text{fill:none;stroke:none}.sql-grammar svg polygon.regexp{fill:#FFFFFF;stroke:#262626}.sql-grammar svg{background-color:#ffffff}.sql-grammar a[name]::before{content:'';display:block;height:80px;margin:-80px 0 0}.sql-grammar a[name]:focus{outline:0}pre[language=\"sql\"][data-crdb-prompt-stripped] code::before{content:\"> \";color:#94e2d5;user-select:none}.mark-yes{color:#008a5e;font-weight:600}.dark .mark-yes{color:#3ddc97}"},{"filePath":"collapse-nav.css","content":"html:not(.crl-nav-off) [data-layout-item=\"sidebar\"] li[data-title]:not([data-active]):not([data-crl-keep])>button+ul,html:not(.crl-nav-off) [data-layout-item=\"mobile-nav\"] li[data-title]:not([data-active]):not([data-crl-keep])>button+ul{display:none}html:not(.crl-nav-off) [data-layout-item=\"sidebar\"] li[data-title]:not([data-active]):not([data-crl-keep])>button svg,html:not(.crl-nav-off) [data-layout-item=\"mobile-nav\"] li[data-title]:not([data-active]):not([data-crl-keep])>button svg{rotate:none!important;transform:none!important}"}],"page":{"pagePath":"docs/v24.3/bytes","slug":"/docs/v24.3/bytes","pageMetadata":{"title":"BYTES","sidebarTitle":"BYTES","old_description":"The BYTES data type stores binary strings of variable length.","canonical":"https://docs.cockroachlabs.com/docs/stable/bytes","description":null,"href":"/docs/v24.3/bytes"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Tip}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`BYTES`}),` `,_jsx(_components.a,{href:`/docs/v24.3/data-types`,children:`data type`}),` stores binary strings of variable length.`]}),`\n`,_jsx(Heading,{level:`2`,id:`aliases`,children:`Aliases`}),`\n`,_jsxs(_components.p,{children:[`In CockroachDB, the following are aliases for `,_jsx(_components.code,{children:`BYTES`}),`:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.code,{children:`BYTEA`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.code,{children:`BLOB`})}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`syntax`,children:`Syntax`}),`\n`,_jsxs(_components.p,{children:[`To express a byte array constant, see the section on `,_jsx(_components.a,{href:`/docs/v24.3/sql-constants#byte-array-literals`,children:`byte array literals`}),` for more details. For example, the following three are equivalent literals for the same byte array: `,_jsx(_components.code,{children:`b'abc'`}),`, `,_jsx(_components.code,{children:`b'\\\\141\\\\142\\\\143'`}),`, `,_jsx(_components.code,{children:`b'\\\\x61\\\\x62\\\\x63'`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`In addition to this syntax, CockroachDB also supports using `,_jsx(_components.a,{href:`/docs/v24.3/sql-constants#string-literals`,children:`string literals`}),`, including the syntax `,_jsx(_components.code,{children:`'...'`}),`, `,_jsx(_components.code,{children:`e'...'`}),` and `,_jsx(_components.code,{children:`x'....'`}),` in contexts where a byte array is otherwise expected.`]}),`\n`,_jsx(Heading,{level:`2`,id:`size`,children:`Size`}),`\n`,_jsxs(_components.p,{children:[`The size of a `,_jsx(_components.code,{children:`BYTES`}),` value is variable, but it’s recommended to keep values under 1 MB to ensure adequate performance. Above that threshold, `,_jsx(_components.a,{href:`/docs/v24.3/architecture/storage-layer`,children:`write amplification`}),` and other considerations may cause significant performance degradation.`]}),`\n`,_jsxs(_components.p,{children:[`We `,_jsx(_components.strong,{children:`strongly recommend`}),` adding size limits to all `,_jsx(_components.a,{href:`/docs/v24.3/indexes`,children:`indexed columns`}),`, which includes columns in `,_jsx(_components.a,{href:`/docs/v24.3/primary-key`,children:`primary keys`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Values exceeding 1 MiB can lead to `,_jsx(_components.a,{href:`/docs/v24.3/architecture/storage-layer`,children:`storage layer write amplification`}),` and cause significant performance degradation or even `,_jsx(_components.a,{href:`/docs/v24.3/cluster-setup-troubleshooting#out-of-memory-oom-crash`,children:`crashes due to OOMs (out of memory errors)`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`To add a size limit using `,_jsx(_components.a,{href:`/docs/v24.3/create-table`,children:_jsx(_components.code,{children:`CREATE TABLE`})}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`CREATE`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` TABLE`}),_jsx(_components.span,{style:{color:`#89B4FA`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#89B4FA`,\"--shiki-dark-font-style\":`italic`},children:` name`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` (`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`first`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` STRING(`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`100`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`), `}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`last`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` STRING(`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`100`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`));`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`To add a size limit using `,_jsx(_components.a,{href:`/docs/v24.3/alter-table#alter-column`,children:_jsx(_components.code,{children:`ALTER TABLE... ALTER COLUMN`})}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`SET`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` enable_experimental_alter_column_type_general `}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`=`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` true;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`ALTER`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` TABLE`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` name`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` ALTER`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` first`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` TYPE`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` STRING(`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`99`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`);`})]}),`\n`]})})}),`\n`,_jsx(Tip,{children:_jsx(_components.p,{children:`If your application requires large binary input in single queries, you can store the blobs somewhere your client can access them (using a cloud storage service, for example), and then reference their addresses from a statement.`})}),`\n`,_jsx(Heading,{level:`2`,id:`example`,children:`Example`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` CREATE`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` TABLE`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` bytes (a `}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`INT`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` PRIMARY KEY`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`, b BYTES);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:` -- explicitly typed BYTES literals`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` INSERT INTO`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` bytes `}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`VALUES`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` (`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`1`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`, b`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'\\\\141\\\\142\\\\143'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`), (`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`2`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`, b`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'\\\\x61\\\\x62\\\\x63'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`), (`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`3`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`, b`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'\\\\141\\\\x62\\\\c'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#9399B2`,\"--shiki-light-font-style\":`italic`,\"--shiki-dark\":`#9399B2`,\"--shiki-dark-font-style\":`italic`},children:` -- string literal implicitly typed as BYTES`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` INSERT INTO`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` bytes `}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:`VALUES`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` (`}),_jsx(_components.span,{style:{color:`#FAB387`,\"--shiki-dark\":`#FAB387`},children:`4`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`, `}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'abc'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` SELECT`}),_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:` *`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` FROM`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:` bytes;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`10`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`10`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`+---+-----+`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`| a | b |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`+---+-----+`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`| 1 | abc |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`| 2 | abc |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`| 3 | abc |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`| 4 | abc |`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`+---+-----+`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`(4 rows)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`2`,id:`supported-conversions`,children:`Supported conversions`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`BYTES`}),` values can be `,_jsx(_components.a,{href:`/docs/v24.3/data-types#data-type-conversions-and-casts`,children:`cast`}),` explicitly to `,_jsx(_components.a,{href:`/docs/v24.3/string`,children:_jsx(_components.code,{children:`STRING`})}),`. This conversion always succeeds. Two conversion modes are supported, controlled by the `,_jsx(_components.a,{href:`/docs/v24.3/set-vars#supported-variables`,children:`session variable`}),` `,_jsx(_components.code,{children:`bytea_output`}),`:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`hex`}),` (default): The output of the conversion starts with the two characters `,_jsx(_components.code,{children:`\\\\`}),`, `,_jsx(_components.code,{children:`x`}),` and the rest of the string is composed by the hexadecimal encoding of each byte in the input. For example, `,_jsx(_components.code,{children:`x'48AA'::STRING`}),` produces `,_jsx(_components.code,{children:`'\\\\x48AA'`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`escape`}),`: The output of the conversion contains each byte in the input, as-is if it is an ASCII character, or encoded using the octal escape format `,_jsx(_components.code,{children:`\\\\NNN`}),` otherwise. For example, `,_jsx(_components.code,{children:`x'48AA'::STRING`}),` produces `,_jsx(_components.code,{children:`'0\\\\252'`}),`.`]}),`\n`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`STRING`}),` values can be cast explicitly to `,_jsx(_components.code,{children:`BYTES`}),`. This conversion will fail if the hexadecimal digits are not valid, or if there is an odd number of them. Two conversion modes are supported:`]}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[`If the string starts with the two special characters `,_jsx(_components.code,{children:`\\\\`}),` and `,_jsx(_components.code,{children:`x`}),` (e.g., `,_jsx(_components.code,{children:`\\\\xAABB`}),`), the rest of the string is interpreted as a sequence of hexadecimal digits. The string is then converted to a byte array where each pair of hexadecimal digits is converted to one byte.`]}),`\n`,_jsx(_components.li,{children:`Otherwise, the string is converted to a byte array that contains its UTF-8 encoding.`}),`\n`]}),`\n`,_jsxs(Heading,{level:`3`,id:`string-vs-bytes`,children:[_jsx(_components.code,{children:`STRING`}),` vs. `,_jsx(_components.code,{children:`BYTES`})]}),`\n`,_jsxs(_components.p,{children:[`While both `,_jsx(_components.code,{children:`STRING`}),` and `,_jsx(_components.code,{children:`BYTES`}),` can appear to have similar behavior in many situations, one should understand their nuance before casting one into the other.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`STRING`}),` treats all of its data as characters, or more specifically, Unicode code points. `,_jsx(_components.code,{children:`BYTES`}),` treats all of its data as a byte string. This difference in implementation can lead to dramatically different behavior. For example, let’s take a complex Unicode character such as ☃ (`,_jsx(_components.a,{href:`https://emojipedia.org/snowman`,children:`the snowman emoji`}),`):`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` SELECT`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` length`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'☃'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`::string);`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` length`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`+--------+`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` 1`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#94E2D5`,\"--shiki-dark\":`#94E2D5`},children:`>`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` SELECT`}),_jsx(_components.span,{style:{color:`#CBA6F7`,\"--shiki-dark\":`#CBA6F7`},children:` length`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`(`}),_jsx(_components.span,{style:{color:`#A6E3A1`,\"--shiki-dark\":`#A6E3A1`},children:`'☃'`}),_jsx(_components.span,{style:{color:`#CDD6F4`,\"--shiki-dark\":`#CDD6F4`},children:`::bytes);`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes catppuccin-mocha catppuccin-mocha`,style:{backgroundColor:`#1e1e2e`,\"--shiki-dark-bg\":`#1e1e2e`,color:`#cdd6f4`,\"--shiki-dark\":`#cdd6f4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` length`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`+--------+`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` 3`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`In this case, `,_jsx(_components.a,{href:`/docs/v24.3/functions-and-operators#string-and-byte-functions`,children:_jsx(_components.code,{children:`LENGTH(string)`})}),` measures the number of Unicode code points present in the string, whereas `,_jsx(_components.a,{href:`/docs/v24.3/functions-and-operators#string-and-byte-functions`,children:_jsx(_components.code,{children:`LENGTH(bytes)`})}),` measures the number of bytes required to store that value. Each character (or Unicode code point) can be encoded using multiple bytes, hence the difference in output between the two.`]}),`\n`,_jsxs(Heading,{level:`4`,id:`translating-literals-to-string-vs-bytes`,children:[`Translating literals to `,_jsx(_components.code,{children:`STRING`}),` vs. `,_jsx(_components.code,{children:`BYTES`})]}),`\n`,_jsx(_components.p,{children:`A literal entered through a SQL client will be translated into a different value based on the type:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`BYTES`}),` give a special meaning to the pair `,_jsx(_components.code,{children:`\\\\x`}),` at the beginning, and translates the rest by substituting pairs of hexadecimal digits to a single byte. For example, `,_jsx(_components.code,{children:`\\\\xff`}),` is equivalent to a single byte with the value of 255. For more information, see `,_jsx(_components.a,{href:`/docs/v24.3/sql-constants#string-literals-with-character-escapes`,children:`SQL Constants: String literals with character escapes`}),`.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.code,{children:`STRING`}),` does not give a special meaning to `,_jsx(_components.code,{children:`\\\\x`}),`, so all characters are treated as distinct Unicode code points. For example, `,_jsx(_components.code,{children:`\\\\xff`}),` is treated as a `,_jsx(_components.code,{children:`STRING`}),` with length 4 ( `,_jsx(_components.code,{children:`\\\\`}),`, `,_jsx(_components.code,{children:`x`}),`, `,_jsx(_components.code,{children:`f`}),`, and `,_jsx(_components.code,{children:`f`}),` ).`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`see-also`,children:`See also`}),`\n`,_jsx(_components.p,{children:_jsx(_components.a,{href:`/docs/v24.3/data-types`,children:`Data Types`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":{"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}},"config":{},"pageMetadata":{"title":"BYTES","sidebarTitle":"BYTES","old_description":"The BYTES data type stores binary strings of variable length.","canonical":"https://docs.cockroachlabs.com/docs/stable/bytes","description":null,"href":"/docs/v24.3/bytes"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Aliases","slug":"aliases","depth":2,"children":[]},{"title":"Syntax","slug":"syntax","depth":2,"children":[]},{"title":"Size","slug":"size","depth":2,"children":[]},{"title":"Example","slug":"example","depth":2,"children":[]},{"title":"Supported conversions","slug":"supported-conversions","depth":2,"children":[{"title":"STRING vs. BYTES","slug":"string-vs-bytes","depth":3,"children":[]},{"title":"Translating literals to STRING vs. BYTES","slug":"translating-literals-to-string-vs-bytes","depth":4,"children":[]}]},{"title":"See also","slug":"see-also","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/cockroachlabs/4695317e415d4eba/kapa.js","/_mintlify/custom/cockroachlabs/40fb45a3cfe42c92/copy-code-prompt.js","/_mintlify/custom/cockroachlabs/3f343c9e8c40397a/collapse-nav.js"],"subdomain":"cockroachlabs","siteName":"CockroachDB","title":"BYTES - CockroachDB","navMaps":{"firstHrefInVersion":{"v26.4":{"href":"/docs/stable/bytes","matchLevel":1},"v26.3":{"href":"/docs/v26.3/bytes","matchLevel":1,"canonicalOverride":true},"v26.2":{"href":"/docs/v26.2/bytes","matchLevel":1,"canonicalOverride":true},"v26.1":{"href":"/docs/v26.1/bytes","matchLevel":1,"canonicalOverride":true},"v25.4":{"href":"/docs/v25.4/bytes","matchLevel":1,"canonicalOverride":true},"v25.3":{"href":"/docs/v25.3/bytes","matchLevel":1,"canonicalOverride":true},"v25.2":{"href":"/docs/v25.2/bytes","matchLevel":1,"canonicalOverride":true},"v25.1":{"href":"/docs/v25.1/bytes","matchLevel":1,"canonicalOverride":true},"v24.3":{"href":"/docs/v24.3/bytes","matchLevel":0},"v24.1":{"href":"/docs/v24.1/bytes","matchLevel":1,"canonicalOverride":true},"v23.2":{"href":"/docs/v23.2/bytes","matchLevel":1,"canonicalOverride":true},"v23.1":{"href":"/docs/v23.1/bytes","matchLevel":1,"canonicalOverride":true}},"firstHrefInLanguage":{}},"lastModified":"2026-11-11T19:16:22.078Z","originalFileLocation":"docs/v24.3/bytes.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"light\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"CockroachDB\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"BYTES - CockroachDB\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"CockroachDB\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.cockroachlabs.com/docs/stable/bytes\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://cockroachlabs.mintlify.site/_mintlify/api/og/v2?division=Data+Types\u0026amp;title=BYTES\u0026amp;theme=4aeed7318cb28bd50868adb3\u0026amp;signature=946ebfa2b7d921d1db5581b136d0a13ff9a661b775ec46de7f50cb49caa1eb82\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"BYTES - CockroachDB\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://cockroachlabs.mintlify.site/_mintlify/api/og/v2?division=Data+Types\u0026amp;title=BYTES\u0026amp;theme=4aeed7318cb28bd50868adb3\u0026amp;signature=946ebfa2b7d921d1db5581b136d0a13ff9a661b775ec46de7f50cb49caa1eb82\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/cockroachlabs/c9BlkJ0WBi2Ma7w-/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"CockroachDB\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#9059FF\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.cockroachlabs.com/docs/stable/bytes\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/v24.3/bytes.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.cockroachlabs.com/#organization\",\"name\":\"CockroachDB\",\"url\":\"https://docs.cockroachlabs.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/cockroachlabs/4WvUnbVuGZfqM4kW/images/CockroachLabs_Wordmark_Black.png?fit=max\u0026auto=format\u0026n=4WvUnbVuGZfqM4kW\u0026q=85\u0026s=54ccae625c9986bf1df8ddc7b2c571f0\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.cockroachlabs.com#website\",\"name\":\"CockroachDB\",\"url\":\"https://docs.cockroachlabs.com\",\"publisher\":{\"@id\":\"https://docs.cockroachlabs.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.cockroachlabs.com/docs/stable/bytes#webpage\",\"url\":\"https://docs.cockroachlabs.com/docs/stable/bytes\",\"name\":\"BYTES\",\"dateModified\":\"2026-11-11T19:16:22.078Z\",\"isPartOf\":{\"@id\":\"https://docs.cockroachlabs.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.cockroachlabs.com/docs/stable/bytes#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.cockroachlabs.com/docs/stable/bytes#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Data Types\",\"item\":\"https://docs.cockroachlabs.com/docs/v24.3/data-types\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"BYTES\",\"item\":\"https://docs.cockroachlabs.com/docs/stable/bytes\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.cockroachlabs.com/docs/stable/bytes#article\",\"headline\":\"BYTES\",\"name\":\"BYTES\",\"url\":\"https://docs.cockroachlabs.com/docs/stable/bytes\",\"mainEntityOfPage\":{\"@id\":\"https://docs.cockroachlabs.com/docs/stable/bytes#webpage\"},\"dateModified\":\"2026-11-11T19:16:22.078Z\",\"publisher\":{\"@id\":\"https://docs.cockroachlabs.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.cockroachlabs.com#website\"}}]}\u003c/script>","agentPointerHref":"/docs/v24.3/bytes.md","siteName":"CockroachDB","nav":{"global":{"anchors":[{"anchor":"University","icon":"graduation-cap","href":"https://learn.cockroachlabs.com/"}]},"products":[{"product":"Cockroach Continuum Cloud","icon":"https://mintlify.s3.us-west-1.amazonaws.com/cockroachlabs/images/continuum/cockroachlabs-symbol.svg","description":"The agentic database cloud","pages":[{"title":"Cockroach Continuum Cloud","href":"/docs/continuum"}]},{"product":"CockroachDB","icon":"database","description":"Distributed SQL database","versions":[{"version":"v26.4","default":true,"tag":"Stable","pages":[{"title":"v26.4","href":"/docs/stable/bytes"}]},{"version":"v26.3","pages":[{"title":"v26.3","href":"/docs/v26.3/bytes"}]},{"version":"v26.2","pages":[{"title":"v26.2","href":"/docs/v26.2/bytes"}]},{"version":"v26.1","pages":[{"title":"v26.1","href":"/docs/v26.1/bytes"}]},{"version":"v25.4","tag":"LTS","pages":[{"title":"v25.4","href":"/docs/v25.4/bytes"}]},{"version":"v25.3","tag":"Unsupported","pages":[{"title":"v25.3","href":"/docs/v25.3/bytes"}]},{"version":"v25.2","tag":"LTS","pages":[{"title":"v25.2","href":"/docs/v25.2/bytes"}]},{"version":"v25.1","tag":"Unsupported","pages":[{"title":"v25.1","href":"/docs/v25.1/bytes"}]},{"version":"v24.3","tag":"LTS","tabs":[{"tab":"Docs","icon":"book-open","pages":[{"title":"Docs","href":"/docs/v24.3"}]},{"tab":"Migrate","icon":"arrow-right-arrow-left","pages":[{"title":"Migrate","href":"/docs/molt/migration-overview"}]},{"tab":"SQL","icon":"code","pages":[{"group":"Statements","pages":[{"title":"SQL Statements","sidebarTitle":"Overview","href":"/docs/v24.3/sql-statements"},{"title":"ALTER BACKUP","sidebarTitle":"ALTER BACKUP","href":"/docs/v24.3/alter-backup"},{"title":"ALTER BACKUP SCHEDULE","sidebarTitle":"ALTER BACKUP SCHEDULE","href":"/docs/v24.3/alter-backup-schedule"},{"title":"ALTER CHANGEFEED","sidebarTitle":"ALTER CHANGEFEED","href":"/docs/v24.3/alter-changefeed"},{"title":"ALTER DATABASE","sidebarTitle":"ALTER DATABASE","href":"/docs/v24.3/alter-database"},{"title":"ALTER DEFAULT PRIVILEGES","sidebarTitle":"ALTER DEFAULT PRIVILEGES","href":"/docs/v24.3/alter-default-privileges"},{"title":"ALTER FUNCTION","sidebarTitle":"ALTER FUNCTION","href":"/docs/v24.3/alter-function"},{"title":"ALTER INDEX","sidebarTitle":"ALTER INDEX","href":"/docs/v24.3/alter-index"},{"title":"ALTER PARTITION","sidebarTitle":"ALTER PARTITION","href":"/docs/v24.3/alter-partition"},{"title":"ALTER PROCEDURE","sidebarTitle":"ALTER PROCEDURE","href":"/docs/v24.3/alter-procedure"},{"title":"ALTER RANGE","sidebarTitle":"ALTER RANGE","href":"/docs/v24.3/alter-range"},{"title":"ALTER ROLE","sidebarTitle":"ALTER ROLE","href":"/docs/v24.3/alter-role"},{"title":"ALTER SCHEMA","sidebarTitle":"ALTER SCHEMA","href":"/docs/v24.3/alter-schema"},{"title":"ALTER SEQUENCE","sidebarTitle":"ALTER SEQUENCE","href":"/docs/v24.3/alter-sequence"},{"title":"ALTER TABLE","sidebarTitle":"ALTER TABLE","href":"/docs/v24.3/alter-table"},{"title":"ALTER TYPE","sidebarTitle":"ALTER TYPE","href":"/docs/v24.3/alter-type"},{"title":"ALTER USER","sidebarTitle":"ALTER USER","href":"/docs/v24.3/alter-user"},{"title":"ALTER VIEW","sidebarTitle":"ALTER VIEW","href":"/docs/v24.3/alter-view"},{"title":"ALTER VIRTUAL CLUSTER","sidebarTitle":"ALTER VIRTUAL CLUSTER","href":"/docs/v24.3/alter-virtual-cluster"},{"title":"BACKUP","sidebarTitle":"BACKUP","href":"/docs/v24.3/backup"},{"title":"BEGIN","sidebarTitle":"BEGIN","href":"/docs/v24.3/begin-transaction"},{"title":"CALL","sidebarTitle":"CALL","href":"/docs/v24.3/call"},{"title":"CANCEL JOB","sidebarTitle":"CANCEL JOB","href":"/docs/v24.3/cancel-job"},{"title":"CANCEL QUERY","sidebarTitle":"CANCEL QUERY","href":"/docs/v24.3/cancel-query"},{"title":"CANCEL SESSION","sidebarTitle":"CANCEL SESSION","href":"/docs/v24.3/cancel-session"},{"title":"COMMENT ON","sidebarTitle":"COMMENT ON","href":"/docs/v24.3/comment-on"},{"title":"COMMIT","sidebarTitle":"COMMIT","href":"/docs/v24.3/commit-transaction"},{"title":"COPY","sidebarTitle":"COPY","href":"/docs/v24.3/copy"},{"title":"CREATE CHANGEFEED","sidebarTitle":"CREATE CHANGEFEED","href":"/docs/v24.3/create-changefeed"},{"title":"CREATE DATABASE","sidebarTitle":"CREATE DATABASE","href":"/docs/v24.3/create-database"},{"title":"CREATE EXTERNAL CONNECTION","sidebarTitle":"CREATE EXTERNAL CONNECTION","href":"/docs/v24.3/create-external-connection"},{"title":"CREATE FUNCTION","sidebarTitle":"CREATE FUNCTION","href":"/docs/v24.3/create-function"},{"title":"CREATE INDEX","sidebarTitle":"CREATE INDEX","href":"/docs/v24.3/create-index"},{"title":"CREATE LOGICAL REPLICATION STREAM","sidebarTitle":"CREATE LOGICAL REPLICATION STREAM","href":"/docs/v24.3/create-logical-replication-stream"},{"title":"CREATE PROCEDURE","sidebarTitle":"CREATE PROCEDURE","href":"/docs/v24.3/create-procedure"},{"title":"CREATE ROLE","sidebarTitle":"CREATE ROLE","href":"/docs/v24.3/create-role"},{"title":"CREATE SCHEDULE FOR BACKUP","sidebarTitle":"CREATE SCHEDULE FOR BACKUP","href":"/docs/v24.3/create-schedule-for-backup"},{"title":"CREATE SCHEDULE FOR CHANGEFEED","sidebarTitle":"CREATE SCHEDULE FOR CHANGEFEED","href":"/docs/v24.3/create-schedule-for-changefeed"},{"title":"CREATE SCHEMA","sidebarTitle":"CREATE SCHEMA","href":"/docs/v24.3/create-schema"},{"title":"CREATE SEQUENCE","sidebarTitle":"CREATE SEQUENCE","href":"/docs/v24.3/create-sequence"},{"title":"CREATE STATISTICS","sidebarTitle":"CREATE STATISTICS","href":"/docs/v24.3/create-statistics"},{"title":"CREATE TABLE","sidebarTitle":"CREATE TABLE","href":"/docs/v24.3/create-table"},{"title":"CREATE TABLE AS","sidebarTitle":"CREATE TABLE AS","href":"/docs/v24.3/create-table-as"},{"title":"CREATE TRIGGER","sidebarTitle":"CREATE TRIGGER","href":"/docs/v24.3/create-trigger"},{"title":"CREATE TYPE","sidebarTitle":"CREATE TYPE","href":"/docs/v24.3/create-type"},{"title":"CREATE USER","sidebarTitle":"CREATE USER","href":"/docs/v24.3/create-user"},{"title":"CREATE VIEW","sidebarTitle":"CREATE VIEW","href":"/docs/v24.3/create-view"},{"title":"CREATE VIRTUAL CLUSTER","sidebarTitle":"CREATE VIRTUAL CLUSTER","href":"/docs/v24.3/create-virtual-cluster"},{"title":"DELETE","sidebarTitle":"DELETE","href":"/docs/v24.3/delete"},{"title":"DROP DATABASE","sidebarTitle":"DROP DATABASE","href":"/docs/v24.3/drop-database"},{"title":"DROP EXTERNAL CONNECTION","sidebarTitle":"DROP EXTERNAL CONNECTION","href":"/docs/v24.3/drop-external-connection"},{"title":"DROP FUNCTION","sidebarTitle":"DROP FUNCTION","href":"/docs/v24.3/drop-function"},{"title":"DROP OWNED BY","sidebarTitle":"DROP OWNED BY","href":"/docs/v24.3/drop-owned-by"},{"title":"DROP TRIGGER","sidebarTitle":"DROP TRIGGER","href":"/docs/v24.3/drop-trigger"},{"title":"DROP TYPE","sidebarTitle":"DROP TYPE","href":"/docs/v24.3/drop-type"},{"title":"DROP INDEX","sidebarTitle":"DROP INDEX","href":"/docs/v24.3/drop-index"},{"title":"DROP PROCEDURE","sidebarTitle":"DROP PROCEDURE","href":"/docs/v24.3/drop-procedure"},{"title":"DROP ROLE","sidebarTitle":"DROP ROLE","href":"/docs/v24.3/drop-role"},{"title":"DROP SCHEDULES","sidebarTitle":"DROP SCHEDULES","href":"/docs/v24.3/drop-schedules"},{"title":"DROP SCHEMA","sidebarTitle":"DROP SCHEMA","href":"/docs/v24.3/drop-schema"},{"title":"DROP SEQUENCE","sidebarTitle":"DROP SEQUENCE","href":"/docs/v24.3/drop-sequence"},{"title":"DROP TABLE","sidebarTitle":"DROP TABLE","href":"/docs/v24.3/drop-table"},{"title":"DROP USER","sidebarTitle":"DROP USER","href":"/docs/v24.3/drop-user"},{"title":"DROP VIEW","sidebarTitle":"DROP VIEW","href":"/docs/v24.3/drop-view"},{"title":"DROP VIRTUAL CLUSTER","sidebarTitle":"DROP VIRTUAL CLUSTER","href":"/docs/v24.3/drop-virtual-cluster"},{"title":"EXPERIMENTAL CHANGEFEED FOR","sidebarTitle":"EXPERIMENTAL CHANGEFEED FOR","href":"/docs/v24.3/changefeed-for"},{"title":"EXPLAIN","sidebarTitle":"EXPLAIN","href":"/docs/v24.3/explain"},{"title":"EXPLAIN ANALYZE","sidebarTitle":"EXPLAIN ANALYZE","href":"/docs/v24.3/explain-analyze"},{"title":"EXPORT","sidebarTitle":"EXPORT","href":"/docs/v24.3/export"},{"title":"GRANT","sidebarTitle":"GRANT","href":"/docs/v24.3/grant"},{"title":"IMPORT INTO","sidebarTitle":"IMPORT INTO","href":"/docs/v24.3/import-into"},{"title":"INSERT","sidebarTitle":"INSERT","href":"/docs/v24.3/insert"},{"title":"JOIN expressions","sidebarTitle":"JOIN","href":"/docs/v24.3/joins"},{"title":"Limit Query Results","sidebarTitle":"LIMIT/OFFSET","href":"/docs/v24.3/limit-offset"},{"title":"ORDER BY","sidebarTitle":"ORDER BY","href":"/docs/v24.3/order-by"},{"title":"PAUSE JOB","sidebarTitle":"PAUSE JOB","href":"/docs/v24.3/pause-job"},{"title":"PAUSE SCHEDULES","sidebarTitle":"PAUSE SCHEDULES","href":"/docs/v24.3/pause-schedules"},{"title":"REASSIGN OWNED","sidebarTitle":"REASSIGN OWNED","href":"/docs/v24.3/reassign-owned"},{"title":"REFRESH","sidebarTitle":"REFRESH","href":"/docs/v24.3/refresh"},{"title":"RELEASE SAVEPOINT","sidebarTitle":"RELEASE SAVEPOINT","href":"/docs/v24.3/release-savepoint"},{"title":"RESET CLUSTER SETTING","sidebarTitle":"RESET CLUSTER SETTING","href":"/docs/v24.3/reset-cluster-setting"},{"title":"RESET {session variable}","sidebarTitle":"RESET {session variable}","href":"/docs/v24.3/reset-vars"},{"title":"RESTORE","sidebarTitle":"RESTORE","href":"/docs/v24.3/restore"},{"title":"RESUME JOB","sidebarTitle":"RESUME JOB","href":"/docs/v24.3/resume-job"},{"title":"RESUME SCHEDULES","sidebarTitle":"RESUME SCHEDULES","href":"/docs/v24.3/resume-schedules"},{"title":"REVOKE","sidebarTitle":"REVOKE","href":"/docs/v24.3/revoke"},{"title":"ROLLBACK","sidebarTitle":"ROLLBACK","href":"/docs/v24.3/rollback-transaction"},{"title":"SAVEPOINT","sidebarTitle":"SAVEPOINT","href":"/docs/v24.3/savepoint"},{"title":"Simple SELECT Clause","sidebarTitle":"SELECT","href":"/docs/v24.3/select-clause"},{"title":"FOR UPDATE and FOR SHARE","sidebarTitle":"FOR UPDATE and FOR SHARE","href":"/docs/v24.3/select-for-update"},{"title":"SET CLUSTER SETTING","sidebarTitle":"SET CLUSTER SETTING","href":"/docs/v24.3/set-cluster-setting"},{"title":"SET {session variable}","sidebarTitle":"SET {session variable}","href":"/docs/v24.3/set-vars"},{"title":"SET TRANSACTION","sidebarTitle":"SET TRANSACTION","href":"/docs/v24.3/set-transaction"},{"title":"SHOW BACKUP","sidebarTitle":"SHOW BACKUP","href":"/docs/v24.3/show-backup"},{"title":"SHOW CLUSTER SETTING","sidebarTitle":"SHOW CLUSTER SETTING","href":"/docs/v24.3/show-cluster-setting"},{"title":"SHOW COLUMNS","sidebarTitle":"SHOW COLUMNS","href":"/docs/v24.3/show-columns"},{"title":"SHOW CONSTRAINTS","sidebarTitle":"SHOW CONSTRAINTS","href":"/docs/v24.3/show-constraints"},{"title":"SHOW CREATE","sidebarTitle":"SHOW CREATE","href":"/docs/v24.3/show-create"},{"title":"SHOW CREATE EXTERNAL CONNECTION","sidebarTitle":"SHOW CREATE EXTERNAL CONNECTION","href":"/docs/v24.3/show-create-external-connection"},{"title":"SHOW CREATE SCHEDULE","sidebarTitle":"SHOW CREATE SCHEDULE","href":"/docs/v24.3/show-create-schedule"},{"title":"SHOW DATABASES","sidebarTitle":"SHOW DATABASES","href":"/docs/v24.3/show-databases"},{"title":"SHOW DEFAULT PRIVILEGES","sidebarTitle":"SHOW DEFAULT PRIVILEGES","href":"/docs/v24.3/show-default-privileges"},{"title":"SHOW DEFAULT SESSION VARIABLES FOR ROLE","sidebarTitle":"SHOW DEFAULT SESSION VARIABLES FOR ROLE","href":"/docs/v24.3/show-default-session-variables-for-role"},{"title":"SHOW ENUMS","sidebarTitle":"SHOW ENUMS","href":"/docs/v24.3/show-enums"},{"title":"SHOW EXTERNAL CONNECTION","sidebarTitle":"SHOW EXTERNAL CONNECTION","href":"/docs/v24.3/show-external-connection"},{"title":"SHOW FULL TABLE SCANS","sidebarTitle":"SHOW FULL TABLE SCANS","href":"/docs/v24.3/show-full-table-scans"},{"title":"SHOW GRANTS","sidebarTitle":"SHOW GRANTS","href":"/docs/v24.3/show-grants"},{"title":"SHOW INDEX","sidebarTitle":"SHOW INDEX","href":"/docs/v24.3/show-index"},{"title":"SHOW JOBS","sidebarTitle":"SHOW JOBS","href":"/docs/v24.3/show-jobs"},{"title":"SHOW LOCALITY","sidebarTitle":"SHOW LOCALITY","href":"/docs/v24.3/show-locality"},{"title":"SHOW LOGICAL REPLICATION JOBS","sidebarTitle":"SHOW LOGICAL REPLICATION JOBS","href":"/docs/v24.3/show-logical-replication-jobs"},{"title":"SHOW PARTITIONS","sidebarTitle":"SHOW PARTITIONS","href":"/docs/v24.3/show-partitions"},{"title":"SHOW RANGES","sidebarTitle":"SHOW RANGES","href":"/docs/v24.3/show-ranges"},{"title":"SHOW RANGE FOR ROW","sidebarTitle":"SHOW RANGE FOR ROW","href":"/docs/v24.3/show-range-for-row"},{"title":"SHOW REGIONS","sidebarTitle":"SHOW REGIONS","href":"/docs/v24.3/show-regions"},{"title":"SHOW {session variable}","sidebarTitle":"SHOW {session variable}","href":"/docs/v24.3/show-vars"},{"title":"SHOW SUPER REGIONS","sidebarTitle":"SHOW SUPER REGIONS","href":"/docs/v24.3/show-super-regions"},{"title":"SHOW SYSTEM GRANTS","sidebarTitle":"SHOW SYSTEM GRANTS","href":"/docs/v24.3/show-system-grants"},{"title":"SHOW ROLES","sidebarTitle":"SHOW ROLES","href":"/docs/v24.3/show-roles"},{"title":"SHOW SCHEDULES","sidebarTitle":"SHOW SCHEDULES","href":"/docs/v24.3/show-schedules"},{"title":"SHOW SCHEMAS","sidebarTitle":"SHOW SCHEMAS","href":"/docs/v24.3/show-schemas"},{"title":"SHOW SEQUENCES","sidebarTitle":"SHOW SEQUENCES","href":"/docs/v24.3/show-sequences"},{"title":"SHOW SESSIONS","sidebarTitle":"SHOW SESSIONS","href":"/docs/v24.3/show-sessions"},{"title":"SHOW STATEMENTS","sidebarTitle":"SHOW STATEMENTS","href":"/docs/v24.3/show-statements"},{"title":"SHOW STATISTICS","sidebarTitle":"SHOW STATISTICS","href":"/docs/v24.3/show-statistics"},{"title":"SHOW SAVEPOINT STATUS","sidebarTitle":"SHOW SAVEPOINT STATUS","href":"/docs/v24.3/show-savepoint-status"},{"title":"SHOW TABLES","sidebarTitle":"SHOW TABLES","href":"/docs/v24.3/show-tables"},{"title":"SHOW TRACE FOR SESSION","sidebarTitle":"SHOW TRACE FOR SESSION","href":"/docs/v24.3/show-trace"},{"title":"SHOW TRANSACTIONS","sidebarTitle":"SHOW TRANSACTIONS","href":"/docs/v24.3/show-transactions"},{"title":"SHOW TYPES","sidebarTitle":"SHOW TYPES","href":"/docs/v24.3/show-types"},{"title":"SHOW USERS","sidebarTitle":"SHOW USERS","href":"/docs/v24.3/show-users"},{"title":"SHOW VIRTUAL CLUSTER","sidebarTitle":"SHOW VIRTUAL CLUSTER","href":"/docs/v24.3/show-virtual-cluster"},{"title":"SHOW ZONE CONFIGURATIONS","sidebarTitle":"SHOW ZONE CONFIGURATIONS","href":"/docs/v24.3/show-zone-configurations"},{"title":"TRUNCATE","sidebarTitle":"TRUNCATE","href":"/docs/v24.3/truncate"},{"title":"UPDATE","sidebarTitle":"UPDATE","href":"/docs/v24.3/update"},{"title":"UPSERT","sidebarTitle":"UPSERT","href":"/docs/v24.3/upsert"},{"title":"WITH (storage parameter)","sidebarTitle":"WITH {storage parameter}","href":"/docs/v24.3/with-storage-parameter"}]},{"group":"Syntax","pages":[{"title":"Keywords \u0026 Identifiers","href":"/docs/v24.3/keywords-and-identifiers"},{"title":"Constants","href":"/docs/v24.3/sql-constants"},{"title":"Selection Queries","href":"/docs/v24.3/selection-queries"},{"title":"Cursors","href":"/docs/v24.3/cursors"},{"title":"Table Expressions","href":"/docs/v24.3/table-expressions"},{"title":"Common Table Expressions (WITH Queries)","sidebarTitle":"Common Table Expressions","href":"/docs/v24.3/common-table-expressions"},{"title":"Name Resolution","href":"/docs/v24.3/sql-name-resolution"},{"title":"NULL Handling","sidebarTitle":"NULL Handling","href":"/docs/v24.3/null-handling"},{"title":"Scalar Expressions","href":"/docs/v24.3/scalar-expressions"},{"title":"User-Defined Functions","href":"/docs/v24.3/user-defined-functions"},{"title":"Stored Procedures","href":"/docs/v24.3/stored-procedures"},{"title":"Triggers","href":"/docs/v24.3/triggers"},{"title":"Window Functions","href":"/docs/v24.3/window-functions"},{"title":"SQL Grammar","sidebarTitle":"Full SQL Grammar","href":"/docs/v24.3/sql-grammar"}]},{"group":"Data Types","pages":[{"title":"Data Types","sidebarTitle":"Overview","href":"/docs/v24.3/data-types"},{"title":"ARRAY","sidebarTitle":"ARRAY","href":"/docs/v24.3/array"},{"title":"BIT","sidebarTitle":"BIT","href":"/docs/v24.3/bit"},{"title":"BOOL","sidebarTitle":"BOOL","description":null,"href":"/docs/v24.3/bool"},{"title":"BYTES","sidebarTitle":"BYTES","href":"/docs/v24.3/bytes"},{"title":"COLLATE","sidebarTitle":"COLLATE","description":null,"href":"/docs/v24.3/collate"},{"title":"DATE","sidebarTitle":"DATE","href":"/docs/v24.3/date"},{"title":"DECIMAL","sidebarTitle":"DECIMAL","href":"/docs/v24.3/decimal"},{"title":"ENUM","sidebarTitle":"ENUM","href":"/docs/v24.3/enum"},{"title":"FLOAT","sidebarTitle":"FLOAT","href":"/docs/v24.3/float"},{"title":"INET","sidebarTitle":"INET","href":"/docs/v24.3/inet"},{"title":"INT","sidebarTitle":"INT","href":"/docs/v24.3/int"},{"title":"INTERVAL","sidebarTitle":"INTERVAL","href":"/docs/v24.3/interval"},{"title":"JSONB","sidebarTitle":"JSONB","href":"/docs/v24.3/jsonb"},{"title":"OID","sidebarTitle":"OID","href":"/docs/v24.3/oid"},{"title":"SERIAL","sidebarTitle":"SERIAL","href":"/docs/v24.3/serial"},{"title":"STRING","sidebarTitle":"STRING","href":"/docs/v24.3/string"},{"title":"TIME / TIMETZ","sidebarTitle":"TIME","href":"/docs/v24.3/time"},{"title":"TIMESTAMP / TIMESTAMPTZ","sidebarTitle":"TIMESTAMP","href":"/docs/v24.3/timestamp"},{"title":"TSQUERY","sidebarTitle":"TSQUERY","href":"/docs/v24.3/tsquery"},{"title":"TSVECTOR","sidebarTitle":"TSVECTOR","href":"/docs/v24.3/tsvector"},{"title":"UUID","sidebarTitle":"UUID","href":"/docs/v24.3/uuid"},{"title":"VECTOR","sidebarTitle":"VECTOR","href":"/docs/v24.3/vector"}]},{"group":"Spatial Data","pages":[{"title":"Spatial Data Overview","sidebarTitle":"Overview","href":"/docs/v24.3/spatial-data-overview"},{"title":"POINT","sidebarTitle":"POINT","href":"/docs/v24.3/point"},{"title":"LINESTRING","sidebarTitle":"LINESTRING","href":"/docs/v24.3/linestring"},{"title":"POLYGON","sidebarTitle":"POLYGON","href":"/docs/v24.3/polygon"},{"title":"MULTIPOINT","sidebarTitle":"MULTIPOINT","href":"/docs/v24.3/multipoint"},{"title":"MULTILINESTRING","sidebarTitle":"MULTILINESTRING","href":"/docs/v24.3/multilinestring"},{"title":"MULTIPOLYGON","sidebarTitle":"MULTIPOLYGON","href":"/docs/v24.3/multipolygon"},{"title":"GEOMETRYCOLLECTION","sidebarTitle":"GEOMETRYCOLLECTION","href":"/docs/v24.3/geometrycollection"},{"title":"Well Known Text","sidebarTitle":"Well Known Text (WKT)","href":"/docs/v24.3/well-known-text"},{"title":"Well Known Binary","sidebarTitle":"Well Known Binary (WKB)","href":"/docs/v24.3/well-known-binary"},{"title":"GeoJSON","href":"/docs/v24.3/geojson"},{"title":"SRID 4326 - longitude and latitude","href":"/docs/v24.3/srid-4326"},{"title":"ST_Contains","sidebarTitle":"ST_Contains","href":"/docs/v24.3/st_contains"},{"title":"ST_Within","sidebarTitle":"ST_Within","href":"/docs/v24.3/st_within"},{"title":"ST_Intersects","sidebarTitle":"ST_Intersects","href":"/docs/v24.3/st_intersects"},{"title":"ST_CoveredBy","sidebarTitle":"ST_CoveredBy","href":"/docs/v24.3/st_coveredby"},{"title":"ST_Covers","sidebarTitle":"ST_Covers","href":"/docs/v24.3/st_covers"},{"title":"ST_Disjoint","sidebarTitle":"ST_Disjoint","href":"/docs/v24.3/st_disjoint"},{"title":"ST_Equals","sidebarTitle":"ST_Equals","href":"/docs/v24.3/st_equals"},{"title":"ST_Overlaps","sidebarTitle":"ST_Overlaps","href":"/docs/v24.3/st_overlaps"},{"title":"ST_Touches","sidebarTitle":"ST_Touches","href":"/docs/v24.3/st_touches"},{"title":"ST_ConvexHull","sidebarTitle":"ST_ConvexHull","href":"/docs/v24.3/st_convexhull"},{"title":"ST_Union","sidebarTitle":"ST_Union","href":"/docs/v24.3/st_union"}]},{"group":"Constraints","pages":[{"title":"Constraints","sidebarTitle":"Overview","href":"/docs/v24.3/constraints"},{"title":"CHECK Constraint","sidebarTitle":"Check","href":"/docs/v24.3/check"},{"title":"Default Value Constraint","sidebarTitle":"Default Value","href":"/docs/v24.3/default-value"},{"title":"Foreign Key Constraint","sidebarTitle":"Foreign Key","href":"/docs/v24.3/foreign-key"},{"title":"NOT NULL constraint","sidebarTitle":"Not Null","href":"/docs/v24.3/not-null"},{"title":"Primary Key Constraint","sidebarTitle":"Primary Key","href":"/docs/v24.3/primary-key"},{"title":"Unique Constraint","sidebarTitle":"Unique","href":"/docs/v24.3/unique"}]},{"title":"Functions and Operators","sidebarTitle":"Functions \u0026 Operators","href":"/docs/v24.3/functions-and-operators"},{"title":"Session Variables","href":"/docs/v24.3/session-variables"},{"title":"PL/pgSQL","href":"/docs/v24.3/plpgsql"}]},{"tab":"Reference","icon":"book","pages":[{"title":"Reference","href":"/docs/v24.3/architecture/glossary"}]},{"tab":"Cluster API","icon":"rocket","pages":[{"title":"Cluster API","href":"/docs/api/cluster"}]},{"tab":"Troubleshoot","icon":"bug","pages":[{"title":"Troubleshoot","href":"/docs/v24.3/troubleshooting-overview"}]}]},{"version":"v24.1","tag":"LTS","pages":[{"title":"v24.1","href":"/docs/v24.1/bytes"}]},{"version":"v23.2","tag":"LTS","pages":[{"title":"v23.2","href":"/docs/v23.2/bytes"}]},{"version":"v23.1","tag":"Unsupported","pages":[{"title":"v23.1","href":"/docs/v23.1/bytes"}]}]},{"product":"Cloud Deployments","icon":"cloud","description":"Fully managed CockroachDB","pages":[{"title":"Cloud Deployments","href":"/docs/cockroachcloud"}]},{"product":"Releases","icon":"list","description":"Version history, support policy \u0026 advisories","pages":[{"title":"Releases","href":"/docs/releases"}]}]},"basePath":"","title":"BYTES - CockroachDB","buildId":"dpl_DqYu5MPb49gWBBbUGgpHQUmCHY3P","deploymentId":"dpl_DqYu5MPb49gWBBbUGgpHQUmCHY3P","dynamics":[],"chunks":[]}