Skip to content

copy_table

MCP tools › Databases

Copy a table to another schema or name, keeping primary key, unique constraints, NOT NULL, defaults and CHECK constraints by default (foreign keys only with foreign_keys=true), and its rows. The structure is read fresh from the database. Without apply=true only the statements are returned. Needs read-schema, and modify-schema plus modify-data (when rows are copied) to apply.

Its results carry text from database: the client is told to treat that as data, never as instructions.

Capabilitydatabase.copy_table
AreaDatabases
Accesschanges database
Reachesdatabase, network
Rightsssh, database-permission, trusted-project
Dry runapply, on unless the call turns it off

Arguments

ArgumentTypeDescription
connectionrequiredstringConnection name from list_connections.
tablerequiredstringTable to copy, in the connection's current schema.
target_schemastringTarget schema (default: the same schema).
target_tablestringTarget table (default <table>_copy in the same schema, else the same name).
primary_keybooleanKeep the primary key (default true).
uniquebooleanKeep unique constraints (default true).
not_nullbooleanKeep NOT NULL (default true).
defaultsbooleanKeep defaults (default true).
checksbooleanKeep CHECK constraints (default true).
foreign_keysbooleanAdd foreign keys to the same referenced tables (default false).
rowsbooleanCopy the rows (default true).
applybooleanRun the copy (default false: only return the statements).

Call it from a shell

ferris-idea call runs one tool with the rights and safe mode of ferris-idea mcp. Replace the folder and the placeholder values.

Terminal window
ferris-idea call ~/my-project copy_table '{"connection":"<string>","table":"<string>"}'
Input schema as JSON
{
"type": "object",
"required": [
"connection",
"table"
],
"properties": {
"connection": {
"description": "Connection name from `list_connections`.",
"type": "string"
},
"table": {
"description": "Table to copy, in the connection's current schema.",
"type": "string"
},
"target_schema": {
"description": "Target schema (default: the same schema).",
"type": [
"string",
"null"
]
},
"target_table": {
"description": "Target table (default `<table>_copy` in the same schema, else the same name).",
"type": [
"string",
"null"
]
},
"primary_key": {
"description": "Keep the primary key (default true).",
"type": [
"boolean",
"null"
]
},
"unique": {
"description": "Keep unique constraints (default true).",
"type": [
"boolean",
"null"
]
},
"not_null": {
"description": "Keep NOT NULL (default true).",
"type": [
"boolean",
"null"
]
},
"defaults": {
"description": "Keep defaults (default true).",
"type": [
"boolean",
"null"
]
},
"checks": {
"description": "Keep CHECK constraints (default true).",
"type": [
"boolean",
"null"
]
},
"foreign_keys": {
"description": "Add foreign keys to the same referenced tables (default false).",
"type": [
"boolean",
"null"
]
},
"rows": {
"description": "Copy the rows (default true).",
"type": [
"boolean",
"null"
]
},
"apply": {
"description": "Run the copy (default false: only return the statements).",
"type": [
"boolean",
"null"
]
}
}
}