SQL Scripts
One file, many statements
A migration script is executed as a sequence of statements, split on ;. Each statement is sent to the database on its own, in order, over plain JDBC. Statements can be anything the database accepts — DDL, DML, GRANT, whatever — and no parameter binding is involved: the SQL in the file is the SQL that runs.
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE INDEX users_name ON users (name);
INSERT INTO users (name) VALUES ('root');
The final statement doesn’t need a trailing semicolon. Whitespace and comments between statements are not sent as statements of their own, so a file that ends with a comment or a stray semicolon is fine.
评论
?
参与讨论