LogoLogo
12.1.0
12.1.0
  • Introduction
  • What's New?
  • Installation & Usage
  • Migration Guide
  • Contributing & Filing Issues
  • Query Builder
    • Getting a New Query
    • Building Queries
      • Selects
      • From
      • For
      • Joins
      • Wheres
      • Order By
      • Group By and Having
      • Limit, Offset, and Pagination
      • Locks
      • Unions
      • Common Table Expressions (i.e. CTEs)
      • Raw Expressions
      • When / Conditionals
      • Query Parameters and Bindings
    • Executing Queries
      • Retrieving Results
      • Aggregates
      • Inserts, Updates, and Deletes
    • Options and Utilities
      • Query Options and Utilities
      • Clone and Reset
      • Return Format
      • Column Formatter
      • Interception Points
    • Debugging
      • sqlCommenter
  • Schema Builder
    • Overview
    • Creating Tables and Views
    • Columns
    • Column Modifiers
    • Column Constraints
    • Creating Table Constraints
    • Altering Tables and Views
    • Dropping Tables and Views
    • Debugging
  • External Links
    • API Docs
    • Source Code
    • Issue Tracker
Powered by GitBook
On this page
  • drop
  • dropIfExists
  • dropView
  • truncate

Was this helpful?

Edit on GitHub
Export as PDF
  1. Schema Builder

Dropping Tables and Views

PreviousAltering Tables and ViewsNextDebugging

Was this helpful?

Dropping tables straightforward in qb.

For dropping columns or constraints, see .

drop

Drop a table from the database.

Argument

Type

Required

Default

Description

table

string

true

The name of the table to drop.

options

struct

false

{}

Options to pass to queryExecute.

execute

boolean

false

true

Run the query immediately after building it.

Example:

SchemaBuilder

schema.drop( "user_logins" );

SQL (MySQL)

DROP TABLE `user_logins`

dropIfExists

Drop a table from the database if it exists.

Argument

Type

Required

Default

Description

table

string

true

The name of the table to drop.

options

struct

false

{}

Options to pass to queryExecute.

execute

boolean

false

true

Run the query immediately after building it.

Example:

SchemaBuilder

schema.dropIfExists( "user_logins" );

SQL (MySQL)

DROP TABLE IF EXISTS `user_logins`

dropView

Drop a table from the database.

Argument
Type
Required
Default
Description

view

string

true

The name of the view to drop.

options

struct

false

{}

Options to pass to queryExecute.

execute

boolean

false

true

Run the query immediately after building it.

Example:

SchemaBuilder

schema.view( "user_logins" );

SQL (MySQL)

DROP VIEW `user_logins`

truncate

Truncates the data from a table.

Argument
Type
Required
Default
Description

table

string

true

The name of the table to truncate the data.

options

struct

false

{}

Options to pass to queryExecute.

execute

boolean

false

true

Run the query immediately after building it.

Example:

SchemaBuilder

schema.truncate( "user_logins" );

SQL (MySQL)

TRUNCATE TABLE `user_logins`
Alter