GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • CODESCRACKER
  • Python
  • Java
  • C++
  • JavaScript
  • SQL
  • Quiz
  • C
  • C#
  • HTML
  • CSS
  • PHP
  • Networking
  • Operating System

This view

  • Original page
  • New address

GeezerVison is showing codescracker.com โ€” Drop Table and Database in SQL

  • SQL Tutorial
  • SQL Tutorial
  • SQL Display Data
  • SQL Update Records
  • SQL Delete Record
  • SQL Alter Table
  • SQL Join Tables
  • SQL Auto Increment
  • SQL Drop Table/Database
  • Computer Programming
  • Learn Python
  • Python Keywords
  • Python Built-in Functions
  • Python Examples
  • Learn C++
  • C++ Examples
  • Learn C
  • C Examples
  • Learn Java
  • Java Examples
  • Learn C#
  • Learn Objective-C
  • Web Development
  • Learn HTML
  • Learn CSS
  • Learn JavaScript
  • JavaScript Examples
  • Learn PHP

Drop Table and Database in SQL

This post will teach you how to drop a table, truncate a table, and delete a database in SQL. Dropping a table means deleting it, whereas truncating a table means deleting all of its data but not the table itself.

Drop a Table in SQL

SQL provides the DROP TABLE statement to accomplish this task. The following is the general syntax for dropping a table in SQL.

DROP TABLE tableName;

For example, the SQL query below will delete the table "mytable" from the database.

DROP TABLE mytable;

Truncate a Table in SQL

To remove or delete all of the data or records in a table, use the TRUNCATE statement instead of the DROP statement. The general form of the TRUNCATE statement that can be used to truncate a table in SQL is shown below.

TRUNCATE TABLE tableName;

For example, the SQL query below will delete all the records from the table named "student".

TRUNCATE TABLE student;

Drop a Database in SQL

The SQL query for dropping a database looks similar to the SQL query for dropping a table. The only difference is that we must replace TABLE with DATABASE. Here is the general form of the SQL DROP DATABASE statement that is used to drop a database.

DROP DATABASE databaseName;

For example, to drop a database named "codescracker," use the following SQL query:

DROP DATABASE codescracker;

That's it. Here I am going to end the SQL tutorial. I hope you like this tutorial ๐Ÿ™‚. If you want to explore more about SQL with me or want to explore other topics with me, then please let me know. You can contact us through any of our social media accounts or directly through the email ID. You can find the link to contact us at the bottom of the page. Thank you, and have a great future ๐Ÿ‘.

SQL Online Test


ยซ Previous Topic CodesCracker.com ยป
Practice Quizzes

Test your programming and computer science knowledge with interactive MCQs and topic-based quizzes.

All Quizzes SQL Quiz Python Quiz Java Quiz C++ Quiz
Popular Topics

Explore the most popular programming and computer science tutorials on CodesCracker.

Python Tutorial Java Tutorial C++ Tutorial SQL Tutorial JavaScript Tutorial HTML Tutorial CSS Tutorial Computer Networking
You are visitor 01402503 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.