SQL
`COPY FROM DATABASE ... TO`
The `COPY FROM DATABASE ... TO` statement copies the entire content from one attached database to another attached database. This includes the schema, including constraints, indexes, sequences, macros, and the data itself.  
```sql
ATTACH 'db1.db' AS db1;
CREATE TABLE db1.tbl AS SELECT 42 AS x, 3 AS y;
CREATE MACRO db1.two_x_plus_y(x, y) AS 2 * x + y;

ATTACH 'db2.db' AS db2;
COPY FROM DATABASE db1 TO db2;
SELECT db2.two_x_plus_y(x, y) AS z FROM db2.tbl;
```  
| z  |
|---:|
| 87 |  
To only copy the **schema** of `db1` to `db2` but omit copying the data, add `SCHEMA` to the statement:  
```sql
COPY FROM DATABASE db1 TO db2 (SCHEMA);
```  
#### Syntax {#docs:sql:statements:copy::syntax}  
<div id="rrdiagram3"></div>