Skip to content

Commit 44514de

Browse files
committed
Improve ALTER TABLE documentation.
1 parent a4a52db commit 44514de

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

docs/ref/mssql.rst

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,30 @@ schema 'public' in the target database with this command::
128128
ALTER TABLE NAMES MATCHING ... IN SCHEMA '...'
129129
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130130

131-
See the MS SQL explanation for this clause above. It works the same in the
132-
context of migrating from MS SQL, only with the added option to specify the
133-
name of the schema where to find the definition of the target tables.
131+
Introduce a comma separated list of table names or *regular expressions*
132+
that you want to target in the pgloader *ALTER TABLE* command. Available
133+
actions are *SET SCHEMA*, *RENAME TO*, and *SET*::
134+
135+
ALTER TABLE NAMES MATCHING ~/_list$/, 'sales_by_store', ~/sales_by/
136+
IN SCHEMA 'dbo'
137+
SET SCHEMA 'mv'
138+
139+
ALTER TABLE NAMES MATCHING 'film' IN SCHEMA 'dbo' RENAME TO 'films'
140+
141+
ALTER TABLE NAMES MATCHING ~/./ IN SCHEMA 'dbo' SET (fillfactor='40')
142+
143+
You can use as many such rules as you need. The list of tables to be
144+
migrated is searched in pgloader memory against the *ALTER TABLE* matching
145+
rules, and for each command pgloader stops at the first matching criteria
146+
(regexp or string).
147+
148+
No *ALTER TABLE* command is sent to PostgreSQL, the modification happens at
149+
the level of the pgloader in-memory representation of your source database
150+
schema. In case of a name change, the mapping is kept and reused in the
151+
*foreign key* and *index* support.
152+
153+
The *SET ()* action takes effect as a *WITH* clause for the `CREATE TABLE`
154+
command that pgloader will run when it has to create a table.
134155

135156
The matching is done in pgloader itself, with a Common Lisp regular
136157
expression lib, so doesn't depend on the *LIKE* implementation of MS SQL,

docs/ref/mysql.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,8 @@ ALTER TABLE NAMES MATCHING
499499
^^^^^^^^^^^^^^^^^^^^^^^^^^
500500

501501
Introduce a comma separated list of table names or *regular expressions*
502-
that you want to target in the pgloader *ALTER TABLE* command. The only two
503-
available actions are *SET SCHEMA* and *RENAME TO*, both take a quoted
504-
string as parameter::
502+
that you want to target in the pgloader *ALTER TABLE* command. Available
503+
actions are *SET SCHEMA*, *RENAME TO*, and *SET*::
505504

506505
ALTER TABLE NAMES MATCHING ~/_list$/, 'sales_by_store', ~/sales_by/
507506
SET SCHEMA 'mv'

0 commit comments

Comments
 (0)