MS SQL Basics Tutorial: Deleting SQL tables

Source: Internet
Author: User

7.6.1 removed with Enterprise Manager

When you right-click the table you want to delete from the Enterprise Manager, select the Delete (delete) option from the shortcut menu, the Delete Object dialog box appears as shown in Figure 7-9, and you can delete the table by clicking the Drop All button. When you click the Show Dependencies button, a dialog box appears as shown in Figure 7-10. It lists the objects that the table relies on and the objects that are dependent on the table. You cannot delete a table when an object relies on a table.

7.6.2 Delete with Drop TABLE command

The drop table command can delete data in a table and table and all indexes, triggers, constraints, and license objects associated with the table (table-related views and stored procedures need to be removed with the drop view and drop procedure commands).

The syntax for the DROP TABLE command is as follows:

DROP TABLE table_name

The table to be deleted if it is not in the current database, specify the database and user name to which it belongs in table_name. Remove the foreign keyword constraint from the table associated with this table before deleting a table. When you delete a table, the bound rule or default value is automatically untied.

Note: system tables cannot be deleted.

Example 7-23: Deletes the table orders1 in the MyDB database.

drop table Mydb.dbo.orders1

Summary of this chapter

This chapter describes the knowledge of creating and managing database tables, and for a detailed introduction to changing the data in the table, see Chapter 11th "Database updates."

See the full set of "MS SQL Basics Tutorials"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.