Drop Table [PostgreSQL MySQL]

API

For the full list of supported methods, see DropTableQueryDROP TABLE - 图1open in new window.

  1. db.NewDropTable().
  2. Model(&strct).
  3. Table("table1"). // quotes table names
  4. TableExpr("table1"). // arbitrary unsafe expression
  5. ModelTableExpr("table1"). // overrides model table name
  6. IfExists().
  7. Cascade().
  8. Restrict().
  9. Exec(ctx)

Example

To drop PostgreSQL/MySQL table:

  1. _, err := db.NewDropTable().Model((*Book)(nil)).IfExists().Exec(ctx)
  2. if err != nil {
  3. panic(err)
  4. }