### Run CockroachDB Cloud Quickstart Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/cockroachcloud/ccloud/quickstart.md Use this command to initiate the guided setup for CockroachDB Cloud. It will guide you through logging in, creating a cluster, and connecting to it. ```shell ccloud quickstart ``` -------------------------------- ### ccloud quickstart output example Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v23.1/setup/sample-setup-parameters.md Example output from the `ccloud quickstart` command, showing the connection parameters for a newly created cluster and SQL user. ```text ? How would you like to connect? Parameters only Looking up cluster ID: succeeded Creating SQL user: succeeded Success! Created SQL user name: maxroach cluster: 37174250-b944-461f-b1c1-3a99edb6af32 Retrieving cluster info: succeeded Connection parameters Database: defaultdb Host: blue-dog-147.6wr.cockroachlabs.cloud Password: ThisIsNotAGoodPassword Port: 26257 Username: maxroach ``` -------------------------------- ### Quickstart with ccloud CLI Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v26.1/setup/sample-setup.md Use the 'ccloud quickstart' command to create a new cluster, set up a SQL user, and get the connection string. ```bash {% include cockroachcloud/ccloud/quickstart.md %} ``` -------------------------------- ### Quickstart with ccloud CLI Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v24.1/setup/sample-setup-parameters.md Use the 'ccloud quickstart' command to create a new cluster, set up a SQL user, and retrieve connection details. This command automates several setup steps. ```bash ccloud quickstart ``` ```text ? How would you like to connect? Parameters only Looking up cluster ID: succeeded Creating SQL user: succeeded Success! Created SQL user name: maxroach cluster: 37174250-b944-461f-b1c1-3a99edb6af32 Retrieving cluster info: succeeded Connection parameters Database: defaultdb Host: blue-dog-147.6wr.cockroachlabs.cloud Password: ThisIsNotAGoodPassword Port: 26257 Username: maxroach ``` -------------------------------- ### Example ccloud connection string Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v26.3/setup/sample-setup.md This is an example of a general connection string provided after running `ccloud quickstart`. It includes connection details for your cluster. ```bash ? How would you like to connect? General connection string Retrieving cluster info: succeeded Downloading cluster cert to /Users/maxroach/.postgresql/root.crt: succeeded postgresql://maxroach:ThisIsNotAGoodPassword@blue-dog-147.6wr.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=%2FUsers%2Fmaxroach%2F.postgresql%2Froot.crt ``` -------------------------------- ### Quickstart with ccloud CLI Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v23.2/setup/sample-setup-certs.md Use the `ccloud quickstart` command to create a new cluster, set up a SQL user, and retrieve the connection string. The connection string is the line starting with `postgresql://`. ```bash ccloud quickstart ``` ```text ? How would you like to connect? General connection string Retrieving cluster info: succeeded Downloading cluster cert to /Users/maxroach/.postgresql/root.crt: succeeded postgresql://maxroach:ThisIsNotAGoodPassword@blue-dog-147.6wr.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=%2FUsers%2Fmaxroach%2F.postgresql%2Froot.crt ``` -------------------------------- ### Oracle Replicator Start Command Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/molt/fetch-data-load-output.md Example commands to start Replicator using the `backfillFromSCN` and `scn` values from the fetch output. ```sql --backfillFromSCN 26685444 --scn 26685786 ``` -------------------------------- ### Run ccloud quickstart Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v26.3/setup/sample-setup-certs.md Use the `ccloud quickstart` command to create a new CockroachDB Serverless cluster, set up a SQL user, and retrieve the connection string. This command simplifies the initial setup process. ```bash {% include cockroachcloud/ccloud/quickstart.md %} ``` -------------------------------- ### Navigate to the application directory Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-nodejs-app-with-cockroachdb-prisma.md Change your current directory to the cloned example application's root folder. This is a prerequisite for installing dependencies. ```shell cd example-app-node-prisma ``` -------------------------------- ### CockroachDB Cloud Quickstart Connection String Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v24.3/setup/sample-setup-jdbc.md This is an example of a connection string obtained after running `ccloud quickstart`. It includes connection details for a CockroachDB Cloud cluster. ```bash postgresql://maxroach:ThisIsNotAGoodPassword@blue-dog-147.6wr.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=%2FUsers%2Fmaxroach%2F.postgresql%2Froot.crt ``` -------------------------------- ### Clone Example Rust App Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-rust-app-with-cockroachdb.md Clone the example application repository to get started. ```shell $ git clone https://github.com/cockroachdb/example-app-rust-postgres ``` -------------------------------- ### Clone and Navigate to Quickstart Repository Source: https://github.com/cockroachdb/docs/blob/main/src/current/cockroachcloud/quickstart.md Commands to download the sample code repository and enter the language-specific directories. ```shell git clone https://github.com/cockroachdb/quickstart-code-samples ``` ```shell cd quickstart-code-samples/java ``` ```shell cd quickstart-code-samples/node ``` -------------------------------- ### Clone the example Django app Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-python-app-with-cockroachdb-django.md Clone the GitHub repository for the example Python Django application to get started. ```shell git clone https://github.com/cockroachlabs/example-app-python-django/ ``` -------------------------------- ### Connect to Secure CockroachDB SQL Client (Manual) Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v23.1/orchestration/test-cluster-secure.md Executes a command to get a shell into a running secure client pod and start the CockroachDB SQL client. Note the different certs-dir path compared to the operator example. ```shell $ kubectl exec -it cockroachdb-client-secure \ -- ./cockroach sql \ --certs-dir=/cockroach-certs \ --host=cockroachdb-public ``` -------------------------------- ### Connect to Secure CockroachDB SQL Client (Operator) Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v23.1/orchestration/test-cluster-secure.md Executes a command to get a shell into a running secure client pod and start the CockroachDB SQL client. Ensure the pod name and certificate directory are correct for your setup. ```shell $ kubectl exec -it cockroachdb-client-secure \ -- ./cockroach sql \ --certs-dir=/cockroach/cockroach-certs \ --host=cockroachdb-public ``` -------------------------------- ### Show CREATE TABLE Statement with Full Output Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/show-create.md This example demonstrates the output of `SHOW CREATE TABLE drivers`, displaying the table name and its complete `CREATE` statement. ```sql SELECT table_name, create_statement FROM drivers; ``` -------------------------------- ### Example `oc get pods` Output Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/deploy-cockroachdb-with-kubernetes-openshift.md This is an example output from the `oc get pods` command, showing the status of various pods including the `crdb-client-secure` pod. ```text NAME READY STATUS RESTARTS AGE cockroach-operator-65c4f6df45-h5r5n 1/1 Running 0 6m11s crdb-client-secure 1/1 Running 0 14m crdb-tls-example-0 1/1 Running 0 3m15s crdb-tls-example-1 1/1 Running 0 103s crdb-tls-example-2 1/1 Running 0 89s ``` -------------------------------- ### Navigate to the example app directory Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-go-app-with-cockroachdb.md Change your current directory to the cloned example application folder to access its files and run commands. ```shell cd example-app-go-pgx ``` -------------------------------- ### Connect to Secure CockroachDB SQL Client (Helm) Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v23.1/orchestration/test-cluster-secure.md Executes a command to get a shell into a running secure client pod and start the CockroachDB SQL client. Note the different certs-dir and host parameters compared to other examples, specific to Helm deployments. ```shell $ kubectl exec -it cockroachdb-client-secure \ -- ./cockroach sql \ --certs-dir=./cockroach-certs \ --host=my-release-cockroachdb-public ``` -------------------------------- ### MySQL Replicator Start Command Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/molt/fetch-data-load-output.md Example command to start Replicator using the `cdc_cursor` from the fetch output. ```sql --defaultGTIDSet 4c658ae6-e8ad-11ef-8449-0242ac140006:1-29 ``` -------------------------------- ### Create and Populate Key-Value Table Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/explain.md This snippet creates a sample key-value table and populates it with initial data. It is a prerequisite for demonstrating the EXPLAIN command. ```sql CREATE TABLE IF NOT EXISTS kv (k INT PRIMARY KEY, v INT); UPSERT INTO kv (k, v) VALUES (1, 5), (2, 10), (3, 15); ``` -------------------------------- ### Install Gradle on macOS Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-spring-app-with-cockroachdb-mybatis.md Use Homebrew to install Gradle on macOS. This is a prerequisite for managing application dependencies in the example. ```shell brew install gradle ``` -------------------------------- ### Create and Select Database Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v24.1/cdc/create-example-db-cdc.md Initialize the demo database and set it as the active session context. ```sql > CREATE DATABASE cdc_demo; ``` ```sql > SET DATABASE = cdc_demo; ``` -------------------------------- ### Start a demo cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/alter-database.md Starts a multi-node demo cluster with a preloaded MovR database. This is a prerequisite for the following examples. ```shell cockroach demo --global --nodes=9 ``` -------------------------------- ### View `intro` Tables Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/cockroach-gen.md Connects to the demo cluster and lists the tables available in the `intro` database. ```shell cockroach sql --url='postgres://demo:demo11762@127.0.0.1:26257?sslmode=require' ``` ```sql > SHOW TABLES FROM intro; ``` -------------------------------- ### Example GCP Principal Source: https://github.com/cockroachdb/docs/blob/main/src/current/cockroachcloud/export-logs.md This is an example of the GCP principal format you will receive after running the command to get the GCP auth principal. ```text CRLKeychainServiceAccount@crl-staging-1abc.iam.gserviceaccount.com ``` -------------------------------- ### Example Pod Output Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v24.2/orchestration/kubernetes-scale-cluster-manual.md This is an example output of `kubectl get pods` after scaling, showing the status of running CockroachDB pods. ```text NAME READY STATUS RESTARTS AGE cockroachdb-0 1/1 Running 0 51m cockroachdb-1 1/1 Running 0 47m cockroachdb-2 1/1 Running 0 3m cockroachdb-3 1/1 Running 0 1m cockroachdb-4 1/1 Running 0 1m cockroachdb-5 1/1 Running 0 1m cockroachdb-client-secure 1/1 Running 0 15m ... ``` -------------------------------- ### Start a Demo Cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/alembic.md Start a virtual cluster for the tutorial. Leave this terminal window open for the duration of the tutorial. ```shell $ cockroach demo --no-example-database ``` -------------------------------- ### Start ggsci Utility Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/goldengate.md Navigate to the GoldenGate installation directory and start the ggsci utility. This is the command-line interface for managing GoldenGate processes. ```shell cd $OGG_PG_HOME ./ggsci ``` -------------------------------- ### Create Database and Table Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/configure-replication-zones.md Creates a sample database and table for demonstrating zone configuration inheritance. ```sql CREATE DATABASE IF NOT EXISTS test; USE test; CREATE TABLE IF NOT EXISTS kv (k INT, v INT); ``` -------------------------------- ### Start Single-Node Insecure Cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v24.2/setup/sample-setup-certs.md This command starts a single-node insecure CockroachDB cluster. Ensure you have CockroachDB installed before running this command. ```bash ./cockroach start-single-node --insecure --store=node1 --listen-addr=localhost:26257 --http-addr=localhost:8080 ``` -------------------------------- ### Start Demo Cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/create-view.md Starts a temporary, in-memory CockroachDB cluster with the startrek schema preloaded. This is a prerequisite for running the view examples. ```shell $ cockroach demo startrek ``` -------------------------------- ### Create and Populate Table Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v26.3/sql/select-for-update-example-partial.md Create a sample table named 'kv' and insert initial data for the example. ```sql CREATE TABLE kv (k INT PRIMARY KEY, v INT); INSERT INTO kv (k, v) VALUES (1, 5), (2, 10), (3, 15); ``` -------------------------------- ### Initialize Database Schema Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-nodejs-app-with-cockroachdb.md The `dbinit.sql` file contains the SQL statements to set up the database schema for the example application. ```sql DROP TABLE IF EXISTS accounts; CREATE TABLE accounts ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), balance DECIMAL(10, 2) NOT NULL ); INSERT INTO accounts (balance) VALUES ('1000.00'), ('0.00'), ('250.00'); ``` -------------------------------- ### Example Pod Status Output Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/deploy-cockroachdb-with-cockroachdb-operator.md Example output from `kubectl get pods` showing the status of the CockroachDB operator and cluster pods. ```text NAME READY STATUS RESTARTS AGE crdb-operator-655fbf7847-zn9v8 1/1 Running 0 10m cockroachdb-9swcg 2/2 Running 0 45s cockroachdb-bn6f7 2/2 Running 0 45s cockroachdb-nk2dw 2/2 Running 0 45s ``` -------------------------------- ### Tutorial Voice Example Source: https://github.com/cockroachdb/docs/blob/main/StyleGuide.md In tutorials, use the second person ('you') for a conversational tone. This example guides the user through cluster management. ```text In this tutorial, you'll start with a new cluster, so stop and clean up any existing clusters. After you create the database, insert some rows. ``` -------------------------------- ### Initialize Example Database Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v23.1/setup/init-bank-sample.md Execute SQL statements from the dbinit.sql file using the `cockroach sql` command. This command connects to the cluster using the DATABASE_URL environment variable. ```shell cat dbinit.sql | cockroach sql --url $DATABASE_URL ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v26.3/orchestration/local-start-kubernetes.md Use this command to start a local Kubernetes cluster with Minikube. Ensure Minikube, a hypervisor, and kubectl are installed beforehand. ```shell minikube start ``` -------------------------------- ### Create Service Principal and Keytab in MIT KDC (Example) Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/gssapi_authentication.md An example demonstrating the creation of a service principal and its corresponding keytab file in MIT KDC. ```shell kadmin.local -q "addprinc postgres/client2.cockroach.industries@COCKROACH.INDUSTRIES" -pw "testing12345!" kadmin.local -q "ktadd -k keytab postgres/client2.cockroach.industries@COCKROACH.INDUSTRIES" ``` -------------------------------- ### Start Minikube Cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v20.2/orchestration/local-start-kubernetes.md Use this command to start a local Kubernetes cluster with minikube. Ensure you have minikube version 0.21.0 or later installed. ```shell $ minikube start ``` -------------------------------- ### Example Table Creation Source: https://github.com/cockroachdb/docs/blob/main/src/current/advisories/a73629.md This SQL snippet demonstrates how to create a partitioned table with a DEFAULT partition using PARTITION BY LIST. This setup can trigger the described internal error in affected versions. ```sql CREATE TABLE abc ( a STRING NOT NULL, b STRING NOT NULL, c INT, PRIMARY KEY (a, b) ) PARTITION BY LIST (a) ( PARTITION p1 VALUES IN (('foo'), ('bar')), PARTITION p2 VALUES IN (('baz')), PARTITION DEFAULT VALUES IN (default) ); ``` -------------------------------- ### Navigate to the repository directory Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-typescript-app-with-cockroachdb.md Change the current directory to the cloned example application repository. ```shell cd example-app-typescript-typeorm ``` -------------------------------- ### Start Demo Cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/follower-reads.md Starts a 3-node demo cluster for testing. ```shell cockroach demo --nodes=3 ``` -------------------------------- ### Install SQLAlchemy with CockroachDB Package Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/install-client-drivers.md Install SQLAlchemy and the CockroachDB-specific Python package. This setup is for using SQLAlchemy with CockroachDB, accounting for database differences. ```shell pip install sqlalchemy sqlalchemy-cockroachdb psycopg2 ``` -------------------------------- ### View demo cluster startup output Source: https://github.com/cockroachdb/docs/blob/main/src/current/_includes/v24.1/sql/start-a-multi-region-demo-cluster.md Example output displayed upon successful initialization of the demo cluster, including connection parameters. ```text # # Welcome to the CockroachDB demo database! # # You are connected to a temporary, in-memory CockroachDB cluster of 9 nodes. # # This demo session will attempt to enable enterprise features # by acquiring a temporary license from Cockroach Labs in the background. # To disable this behavior, set the environment variable # COCKROACH_SKIP_ENABLING_DIAGNOSTIC_REPORTING=true. # # Reminder: your changes to data stored in the demo session will not be saved! # # Connection parameters: # (webui) http://127.0.0.1:8080/demologin?password=demo76950&username=demo # (sql) postgres://demo:demo76950@127.0.0.1:26257?sslmode=require # (sql/unix) postgres://demo:demo76950@?host=%2Fvar%2Ffolders%2Fc8%2Fb_q93vjj0ybfz0fz0z8vy9zc0000gp%2FT%2Fdemo070856957&port=26257 # # To display connection parameters for other nodes, use \demo ls. # # The user "demo" with password "demo76950" has been created. Use it to access the Web UI! # # Server version: CockroachDB CCL v21.1.2 (x86_64-apple-darwin19, built 2021/06/07 18:13:04, go1.15.11) (same version as client) # Cluster ID: bfd9fc91-69bd-4417-a2f7-66e556bf2cfd # Organization: Cockroach Demo # # Enter \? for a brief introduction. # ``` -------------------------------- ### Generate Example SQL Data (Intro) Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/cockroach-gen.md Generates introductory example SQL data and pipes it to the `cockroach sql` client for immediate use or inspection. ```shell $ cockroach gen example-data intro | cockroach sql ``` -------------------------------- ### Start Node 3 Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/demo-replication-and-rebalancing.md Starts the third node, completing the 3-node cluster setup. Verify the --join parameter includes all nodes. ```shell $ cockroach start \ --certs-dir=certs \ --store=rep-node3 \ --listen-addr=localhost:26259 \ --http-addr=localhost:8082 \ --join=localhost:26257,localhost:26258,localhost:26259 ``` -------------------------------- ### Make jOOQ installation script executable Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-java-app-with-cockroachdb-jooq.md Grant execute permissions to the jOOQ installation script before running it. This is part of the jOOQ setup process. ```shell chmod +x maven-install.sh ``` -------------------------------- ### Example CREATE TABLE statement with partitions and zones Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/show-partitions.md This output shows a table with partitions defined by `LIST (city)` and specific zone configurations applied to each partition. ```sql CREATE TABLE users ( id UUID NOT NULL, city VARCHAR NOT NULL, name VARCHAR NULL, address VARCHAR NULL, credit_card VARCHAR NULL, CONSTRAINT "primary" PRIMARY KEY (city ASC, id ASC), FAMILY "primary" (id, city, name, address, credit_card) ) PARTITION BY LIST (city) ( PARTITION us_west VALUES IN (('seattle'), ('san francisco'), ('los angeles')), PARTITION us_east VALUES IN (('new york'), ('boston'), ('washington dc')), PARTITION europe_west VALUES IN (('amsterdam'), ('paris'), ('rome')) ); ALTER PARTITION europe_west OF INDEX movr.public.users@users_pkey CONFIGURE ZONE USING constraints = '[+region=europe-west1]'; ALTER PARTITION us_east OF INDEX movr.public.users@users_pkey CONFIGURE ZONE USING constraints = '[+region=us-east1]'; ALTER PARTITION us_west OF INDEX movr.public.users@users_pkey CONFIGURE ZONE USING constraints = '[+region=us-west1]' ``` -------------------------------- ### Start Pulsar standalone cluster Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/changefeed-examples.md Use this command to start a standalone Apache Pulsar cluster for testing. Ensure Pulsar is installed and its bin directory is in your PATH. ```shell bin/pulsar standalone ``` -------------------------------- ### Run Setup Script Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/orchestrate-cockroachdb-with-kubernetes-multi-cluster.md Execute the `setup.py` script to create resources and initialize the CockroachDB cluster across your Kubernetes clusters. ```shell python setup.py ``` -------------------------------- ### Retrieve Node Starting Details from Log File Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/cockroach-start-single-node.md Example command to retrieve the 'node starting' details from the `cockroach.log` file, which are also printed to standard output. ```shell grep 'node starting' node1/logs/cockroach.log -A 11 ``` -------------------------------- ### SQL Command and Output Example Source: https://github.com/cockroachdb/docs/blob/main/StyleGuide.md Demonstrates how to display a SQL command and its output using separate code blocks for clarity. This approach helps users follow the execution flow. ```sql SHOW VIRTUAL CLUSTERS; ``` ```text id | name | data_state | service_mode -----+--------+-------------+--------------- 1 | system | ready | shared 3 | main | replicating | none (2 rows) ``` -------------------------------- ### Install Gradle on Debian-based Linux Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/build-a-spring-app-with-cockroachdb-mybatis.md Use apt-get to install Gradle on Debian-based Linux distributions like Ubuntu. This is a prerequisite for managing application dependencies in the example. ```shell apt-get install gradle ``` -------------------------------- ### Launch SQL client and show tables Source: https://github.com/cockroachdb/docs/blob/main/src/current/v26.3/cockroach-workload.md Connect to the SQL client and display all tables within the movr database. ```shell $ cockroach sql --insecure ``` ```sql > SHOW TABLES FROM movr; ```