Skip to content

Latest commit

 

History

History
23 lines (18 loc) · 386 Bytes

alter_table.md

File metadata and controls

23 lines (18 loc) · 386 Bytes

Schema modification

sqlc understands ALTER TABLE statements when parsing SQL.

CREATE TABLE authors (
  id          SERIAL PRIMARY KEY,
  birth_year  int    NOT NULL
);

ALTER TABLE authors ADD COLUMN bio text NOT NULL;
ALTER TABLE authors DROP COLUMN birth_year;
ALTER TABLE authors RENAME TO writers;
package db

type Writer struct {
	ID  int
	Bio string
}