Documentation Index
Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
Use this file to discover all available pages before exploring further.
Problem
You need unique identifiers for rows in your data pipeline. Maybe you’re building an API that returns specific records, tracking processing status across systems, or joining data from multiple sources.Solution
What’s in this recipe:- Create tables with auto-generated UUID primary keys
- Add UUID columns to existing tables
- Generate UUIDs with
uuid7()
uuid7() to generate UUIDs for each row. Define it in the
schema with {'column_name': uuid7()} syntax, or add it to existing
tables with add_computed_column().
Setup
Create a table with a UUID primary key
Useuuid7() in your schema to create a column that auto-generates
UUIDs:
Created table ‘products’.
Inserted 3 rows with 0 errors in 0.02 s (191.21 rows/s)
3 rows inserted.
Add a UUID column to an existing table
You can add a UUID column to a table that already exists usingadd_computed_column():
Created table ‘orders’.
Inserted 2 rows with 0 errors in 0.01 s (310.49 rows/s)
2 rows inserted.
Added 2 column values with 0 errors in 0.02 s (98.14 rows/s)
2 rows updated.
Explanation
Two ways to add UUIDs: Both useuuid7() which generates UUIDv7 (time-based) identifiers:
- 128-bit values
- Formatted as 32 hex digits with hyphens:
018e65c5-35e5-7c5d-8f37-f1c5b9c8a7b2 - Time-ordered for better database performance
- Virtually guaranteed unique (collision probability is negligible)