> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating Data Sinks

> Copy-paste examples of how to create data sinks with SQL

Several authentication schemes across multiple consumers are supported. For a
detailed overview of all of the consumer-specific options, see the
[SQL documentation](/content/sql/ddl#sql-create-data-sink).

<Info>
  Creating an authenticated *data sink* may require creating a
  corresponding  [credential](/content/sql/ddl#sql-create-credential) object to
  store the authentication information and then referencing that object when
  creating the *data sink*. See [Creating Credentials](/content/snippets/create-credentials) for
  examples.
</Info>

<a id="snippet-sql-create-data-sink-azure" />

## Azure BLOB

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SINK azure_dsink
  LOCATION = 'AZURE'
  WITH OPTIONS
  (
      CREDENTIAL = 'azure_cred',
      CONTAINER NAME = 'samplecontainer'
  )
  ```

  ```sql Managed Credentials theme={null}
  CREATE DATA SINK azure_dsink
  LOCATION = 'AZURE'
  WITH OPTIONS
  (
      USE_MANAGED_CREDENTIALS = true,
      STORAGE ACCOUNT NAME = 'sampleacc',
      CONTAINER NAME = 'samplecontainer',
      TENANT ID = 'x0xxx10-00x0-0x01-0xxx-x0x0x01xx100'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-sink-gcs" />

## Google Cloud Storage

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SINK gcs_dsink
  LOCATION = 'GCS'
  WITH OPTIONS
  (
  	CREDENTIAL = 'gcs_cred',
  	GCS_BUCKET_NAME = 'gcs-private'
  )
  ```

  ```sql Managed Credentials theme={null}
  CREATE DATA SINK gcs_dsink
  LOCATION = 'GCS'
  WITH OPTIONS
  (
  	USE_MANAGED_CREDENTIALS = true,
  	GCS_BUCKET_NAME = 'gcs-private'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE DATA SINK gcs_dsink
  LOCATION = 'GCS'
  WITH OPTIONS (GCS_BUCKET_NAME = 'gcs-public')
  ```

  ```sql JSON Key theme={null}
  CREATE DATA SINK gcs_dsink
  LOCATION = 'GCS'
  WITH OPTIONS
  (
  	GCS_SERVICE_ACCOUNT_KEYS = '
  	{
  		"type": "service_account",
  		"project_id": "auser",
  		"private_key_id": "abcdef1234567890",
  		"private_key": "-----BEGIN PRIVATE KEY-----\nABCDEFG=\n-----END PRIVATE KEY-----\n",
  		"client_email": "auser@auser.iam.gserviceaccount.com",
  		"client_id": "1234567890",
  		"auth_uri": "https://accounts.google.com/o/oauth2/auth",
  		"token_uri": "https://oauth2.googleapis.com/token",
  		"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  		"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/auser%40auser.iam.gserviceaccount.com"
  	}',
  	GCS_BUCKET_NAME = 'gcs-private'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-sink-hdfs" />

## HDFS

```sql Credential theme={null}
CREATE DATA SINK hdfs_dsink
LOCATION = 'HDFS://example.com:8020'
WITH OPTIONS
(
	CREDENTIAL = 'hdfs_cred'
)
```

<a id="snippet-sql-create-data-sink-jdbc" />

## JDBC

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SINK jdbc_dsink
  LOCATION = 'jdbc:postgresql://localhost:5432/ki_home'
  WITH OPTIONS
  (
  	CREDENTIAL = 'jdbc_cred',
  	JDBC_DRIVER_CLASS_NAME = 'org.postgresql.Driver',
  	JDBC_DRIVER_JAR_PATH = 'kifs://drivers/postgresql.jar'
  )
  ```

  ```sql Password in URL theme={null}
  CREATE DATA SINK jdbc_dsink
  LOCATION = 'jdbc:postgresql://localhost:5432/ki_home?user=dsink_user&password=Passw0rd!'
  WITH OPTIONS
  (
  	JDBC_DRIVER_CLASS_NAME = 'org.postgresql.Driver',
  	JDBC_DRIVER_JAR_PATH = 'kifs://drivers/postgresql.jar'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-sink-kafka" />

## Kafka

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SINK kafka_dsink
  LOCATION = 'kafka://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample',
      CREDENTIAL = 'kafka_cred'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE DATA SINK kafka_dsink
  LOCATION = 'kafka://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-sink-local" />

## Local Table

```sql User Auth theme={null}
CREATE DATA SINK local_table_dsink
LOCATION = 'table://example.local_target_table'
```

<a id="snippet-sql-create-data-sink-s3" />

## S3

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SINK s3_dsink
  LOCATION = 'S3'
  WITH OPTIONS
  (
      CREDENTIAL = 's3_cred',
      BUCKET NAME = 'samplebucket',
      REGION = 'us-east-2'
  )
  ```

  ```sql Managed Credentials theme={null}
  CREATE OR REPLACE DATA SINK s3_dsink
  LOCATION = 'S3'
  WITH OPTIONS
  (
      USE_MANAGED_CREDENTIALS = true,
      BUCKET NAME = 'samplebucket',
      REGION = 'us-east-1'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE DATA SINK s3_dsink
  LOCATION = 'S3'
  WITH OPTIONS
  (
      BUCKET NAME = 'quickstartpublic',
      REGION = 'us-west-1'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-sink-webhook" />

## Webhook

<CodeGroup>
  ```sql HTTP theme={null}
  CREATE DATA SINK http_dsink
  LOCATION = 'http://example.com/webhook'
  ```

  ```sql HTTPS theme={null}
  CREATE DATA SINK https_dsink
  LOCATION = 'https://example.com/webhook'
  WITH OPTIONS
  (
  	CREDENTIAL = 'https_cred'
  )
  ```
</CodeGroup>
