Run your first query
In this guide, you will create a product table, save one row and find it with SQL. You need a running OriginChainDB instance and a terminal with cURL. The examples use Bash syntax.
- Connect to a ready instanceKeep the full connection address unchanged.
- Create the product tableDeclare its ID, name and price fields.
- Write the Trail mug rowStore its price as 1990 cents.
- Query products under 2000 centsCheck that the returned record is the one you saved.
Connect to your database
Create an account, launch a database and wait until it is ready. Open Connect in the console and copy the complete HTTPS database address and the credential offered for that connection.
export OC_URL="https://your-complete-database-address"
# Load OC_TOKEN from your environment or secret manager.
: "${OC_TOKEN:?Set OC_TOKEN before continuing}"Replace OC_URL with the exact address from Connect, including its path. Keep the credential private and choose access that allows schemas, row writes and SQL. Connection setup explains which credential is available for your instance.
If your administrator supplied an explicit host-and-tenant connection instead, use the tenant-path API quickstart. Do not add or remove a tenant path from the address supplied by Connect.
Create a table and add data
This creates quickstart.products with a string ID, a name and an integer price in cents.
Create the table through the HTTP SQL endpoint
curl --fail-with-body -X POST "${OC_URL%/}/sql" \
-H "Authorization: Bearer $OC_TOKEN" \
-H "Content-Type: application/json" \
-d '{"sql":"CREATE TABLE quickstart.products (id TEXT PRIMARY KEY, name TEXT, price_cents BIGINT)","params":[]}'Add one product
curl --fail-with-body -X POST "${OC_URL%/}/sql" \
-H "Authorization: Bearer $OC_TOKEN" \
-H "Content-Type: application/json" \
-d '{"sql":"INSERT INTO quickstart.products (id, name, price_cents) VALUES ($1, $2, $3)","params":["product-001","Trail mug",1990]}'Run creation and insertion once in a development database. If the table or product already exists, inspect it before rerunning a write. Wait for each request to succeed; a timeout does not prove that a write failed. See the error reference for a rejected request.
Ask for the products you need
Run a SQL query against the same table. This selects products priced below 2,000 cents.
curl --fail-with-body -X POST "${OC_URL%/}/sql" \
-H "Authorization: Bearer $OC_TOKEN" \
-H "Content-Type: application/json" \
-d '{"sql":"SELECT id, name, price_cents FROM quickstart.products WHERE price_cents < $1 LIMIT 10","params":[2000]}'Expected result from quickstart.products
| id | name | price_cents |
|---|---|---|
| product-001 | Trail mug | 1990 |
You've created a schema, written a record and queried it. Change the price filter and run the query again to see how the result changes.
Choose your next step.
Once the query works, call the same HTTP API from your application or choose a compatible SDK. The SDK directory distinguishes published packages from the new release candidates.
Connect your app — Choose your language and check its available SDK version.
Search by meaning — Prepare embeddings and find related content.
Find exact words — Match keywords and rank text with BM25.
Follow relationships — Connect records and traverse their links.