Skip to main content

Query data

For more information about database manipulation, see MotherDuck SQL reference.

MotherDuck uses DuckDB under the hood, so nearly all DuckDB SQL works in MotherDuck without differences.

MotherDuck leverages “hybrid execution” to decide the best location to execute queries, including across multiple locations. For example, if your data lives on your laptop, MotherDuck executes queries against that data on your laptop. Similarly, if you are joining data on your laptop to data on Amazon S3, MotherDuck executes each part of the query where data lives before bringing it together to be joined locally.

Querying data In MotherDuck

You can query data loaded into MotherDuck the same way you query data in your DuckDB databases. MotherDuck executes these queries using resources in the cloud.

# table table_name is in MotherDuck storage
con.sql("SELECT * FROM table_name").show();

Querying data on your machine

You can use MotherDuck to query files on your local machine. These queries execute using your machine’s resources.

# query a Parquet file on your local machine
con.sql("SELECT * FROM '~/file.parquet'").show();

# query a table in a local DuckDB database
con.sql("SELECT * FROM local_table").show();

Joining data across multiple locations

You can use MotherDuck to join data:

  • In MotherDuck
  • On S3 or other cloud object stores (Azure, GCS, R2, etc)
  • On your local machine

What's next ?

Ready to share your DuckDB data with your colleagues? Read up on Sharing In MotherDuck.