Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified media/tidb-cloud-lake/staging-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions tidb-cloud-lake/sql/create-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,29 @@ To create a database, the user performing the operation or the [current_role](/t

## Examples

### Creating a Basic Database
Comment thread
lilin90 marked this conversation as resolved.

The following example creates a database named `test`:

```sql
CREATE DATABASE test;
```

The following example creates a database with a default storage connection and path:
### Creating a Database with a Default Storage Connection
Comment thread
lilin90 marked this conversation as resolved.

The following example creates a connection using an AWS IAM role and then creates a database that uses this connection as its default storage. Using an IAM role is more secure than access keys because it doesn't require storing credentials in {{{ .lake }}}.

```sql
CREATE CONNECTION my_s3 STORAGE_TYPE = 's3' ACCESS_KEY_ID = '<key>' SECRET_ACCESS_KEY = '<secret>';
CREATE CONNECTION my_s3
STORAGE_TYPE = 's3'
ROLE_ARN = 'arn:aws:iam::987654321987:role/lake-test';

CREATE DATABASE analytics OPTIONS (
DEFAULT_STORAGE_CONNECTION = 'my_s3',
DEFAULT_STORAGE_PATH = 's3://mybucket/analytics/'
);
```

> **Note:**
>
> To use IAM roles with {{{ .lake }}}, you need to set up a trust relationship between your AWS account and {{{ .lake }}}. See [Authenticate with AWS IAM Role](/tidb-cloud-lake/guides/authenticate-with-aws-iam-role.md) for detailed instructions.