GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • DOCUMENTATION
  • Tutorials
  • Developer
  • SQL Reference
  • Integrations
  • Releases
  • Data Types
  • Boolean
  • Binary
  • String
  • Numeric
  • Decimal
  • Date & Time
  • Interval

This view

  • Original page
  • New address

GeezerVison is showing docs.databend.com — Array | Databend

Overview​

ARRAY(T) stores variable-length collections whose elements all share the type T. Define the element type when creating a table and use array functions to read or transform the values.

note

Databend arrays are 1-based. arr[1] returns the first element and arr[n] the last.

Examples​

CREATE TABLE array_samples (arr ARRAY(INT64));

INSERT INTO array_samples VALUES ([1, 2, 3]), ([10, 20]);

SELECT
arr,
arr[1] AS first_elem,
arr[2] AS second_elem
FROM array_samples;

Result:

┌────────────┬────────────┬──────────────┐
│ arr │ first_elem │ second_elem │
├────────────┼────────────┼──────────────┤
│ [1,2,3] │ 1 │ 2 │
│ [10,20] │ 10 │ 20 │
└────────────┴────────────┴──────────────┘
-- Index 0 always returns NULL because arrays are 1-based.
SELECT arr[0] AS zeroth_elem FROM array_samples;

Result:

┌─────────────┐
│ zeroth_elem │
├─────────────┤
│ NULL │
│ NULL │
└─────────────┘
Did this page help you?
Yes
FeedBack
Raise issue
Join our growing community
GitHub
🌟 9.5K Stars
Slack
X(Twitter)
YouTube
Or simply contact us directly
Contact Us
Explore Databend Cloud
  • Overview
  • Examples
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.