# 2 - Loading Your Data
> Learn how to load your own datasets into MotherDuck
In this section, you'll learn how to load your own data into MotherDuck and run powerful hybrid queries that combine local and cloud data.

👈 **[Go back to Part 1: Running Your First Query](../part-1)**

## Loading your data

### Loading data using CREATE TABLE AS SELECT

The `CREATE TABLE AS SELECT` (CTAS) pattern creates a new table and populates it with data in a single operation:

```sql
CREATE OR REPLACE TABLE docs_playground.my_table AS SELECT * FROM 'my_data.csv';
```

### Loading data using INSERT INTO

The `INSERT INTO` pattern lets you append data to existing tables, update specific records, and manage data incrementally:

```sql
-- First, create the table structure
CREATE TABLE docs_playground.my_table AS SELECT * FROM 'my_data.csv' LIMIT 0;

-- Then load data incrementally
INSERT INTO docs_playground.my_table SELECT * FROM 'new_data.csv';
INSERT OR REPLACE INTO docs_playground.my_table SELECT * FROM 'updated_data.csv';
```

:::tip
While `CREATE TABLE AS SELECT` is convenient for one-time loads or small datasets, for larger datasets and production workflows, we recommend using `INSERT INTO`. This approach provides better control over data loading, allows for incremental updates, and is more efficient for ongoing data management.
:::

There are several ways to get your data into MotherDuck, depending on where your data lives:

### From local file system

To load data files from your file system into MotherDuck, you'll need:

1. A valid MotherDuck token stored as the `motherduck_token` environment variable
2. A DuckDB client (DuckDB CLI, Python, etc.)

To create a MotherDuck token, navigate to the MotherDuck UI, click your organization name in the top left, then go to **Settings > Integrations > Access Token**. For detailed instructions, see our [authentication guide](../../key-tasks/authenticating-and-connecting-to-motherduck/authenticating-to-motherduck/authenticating-to-motherduck.md).

### DuckDB CLI

Install the DuckDB CLI for macOS/Linux. For other operating systems, see the [DuckDB installation guide](https://duckdb.org/docs/installation/).

```bash
curl -s https://install.motherduck.com | sh
```

Launch the DuckDB CLI:

```bash
duckdb
```

```sql
-- Connect to MotherDuck
ATTACH 'md:';

-- Load CSV data from your local file into the playground database
CREATE TABLE docs_playground.popular_currency_rate_dollar AS
SELECT * FROM './popular_currency_rate_dollar.csv';
```

### Python

Install DuckDB using your preferred package manager, such as pip:

```bash
pip install duckdb
```

```python
import duckdb

# Connect to MotherDuck
conn = duckdb.connect('md:')

# Load data into the playground database (automatically created)
conn.execute("""
    CREATE TABLE docs_playground.popular_currency_rate_dollar AS
    SELECT * FROM './popular_currency_rate_dollar.csv'
""")
```

### MotherDuck UI

Head over to the `Add data` button in the MotherDuck UI and upload your file directly. This works great for smaller files and provides a visual interface.

![Add file](./img/screenshot_add_data.png)

![load data](./img/screenshot_loading_data2.png)

### From remote storage (S3, GCS, etc.)

For data already stored in cloud storage, you have multiple options:

### SQL

You can load public remote data into your playground database using our interactive SQL editor:

<MotherDuckSQLEditor
  database="docs_playground"
  query="CREATE TABLE IF NOT EXISTS docs_playground.popular_currency_rate_dollar AS SELECT * FROM 's3://us-prd-motherduck-open-datasets/misc/csv/popular_currency_rate_dollar.csv';" />

### DuckDB CLI

```sql
ATTACH 'md:';
CREATE TABLE docs_playground.popular_currency_rate_dollar AS
SELECT * FROM 's3://us-prd-motherduck-open-datasets/misc/csv/popular_currency_rate_dollar.csv';
```

### Python

```python
import duckdb
conn = duckdb.connect('md:')
conn.execute("""
    CREATE TABLE docs_playground.popular_currency_rate_dollar AS
    SELECT * FROM 's3://your-bucket/your-file.csv'
""")
```

### MotherDuck UI

1. In the left panel of the UI, click **Add data**
2. Select **From cloud storage**
3. For a publicly accessible bucket, skip creating a secret
4. Switch to **Wildcard** mode, and enter the S3 path `s3://us-prd-motherduck-open-datasets/**/popular_currency_rate_dollar.csv`
5. Name the table `popular_currency_rate_dollar` and select `docs_playground` as the destination database
6. Click **Create table**

![Create table from S3](./img/screenshot_ui_create_table_from_s3.png)

For more details, see [Loading Data from Cloud Storage](../../key-tasks/loading-data-into-motherduck/loading-data-from-cloud-or-https.md).

:::info
For private AWS s3 buckets, you'll need to configure AWS credentials. Check our [AWS s3 authentication guide](../../integrations/cloud-storage/amazon-s3.mdx) for details.
:::

### Querying your data

Once your data is loaded, you can query it from any interface:

### SQL

<MotherDuckSQLEditor
  database="docs_playground"
  query="FROM docs_playground.popular_currency_rate_dollar LIMIT 10;" />

### DuckDB CLI

```sql
ATTACH 'md:';
FROM docs_playground.popular_currency_rate_dollar LIMIT 10;
```

### Python

```python
import duckdb

# Connect to MotherDuck
conn = duckdb.connect('md:')

# Query your data
result = conn.sql("FROM docs_playground.popular_currency_rate_dollar LIMIT 10").fetchall()
print(result)
```

👉 **[Continue to Part 3: Sharing Your Database →](../part-3)**


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/getting-started/e2e-tutorial/part-2/",
  "page_title": "2 - Loading Your Data",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
