Drop Table [PostgreSQL MySQL]

API

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

1. db.NewDropTable().

3. Model(&strct).

5. Table("table1"). // quotes table names
6. TableExpr("table1"). // arbitrary unsafe expression
7. ModelTableExpr("table1"). // overrides model table name

9. IfExists().

11. Cascade().
12. Restrict().

14. 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. }