SQL中Drop刪除表命令解析
如果您才接觸SQL不久,SQL的各種命令是一定需要掌握的,下面為您介紹SQL命令中的Drop刪除表,供您參考,希望對您有所幫助。
Drop Index
取消索引
You can delete an existing index in a table with the DROP INDEX statement.
你可以將現(xiàn)有的索引通過DROP INDEX語句進行取消操作。
Syntax for Microsoft SQLJet (and Microsoft Access):
在Microsoft SQLJet (和 Microsoft Access)中的語法是這樣的:
DROP INDEX index_name ON table_name
Syntax for MS SQL Server:
MS SQL Server的語法是這樣:
DROP INDEX table_name.index_name
Syntax for IBM DB2 and Oracle:
IBM DB2和Oracle的語法為:
DROP INDEX index_name
Syntax for MySQL:
MySql則是這樣:
ALTER TABLE table_name DROP INDEX index_name
--------------------------------------------------------------------------------
Delete a Table or Database
刪除一張表或是一數(shù)據(jù)庫
To delete a table (the table structure, attributes, and indexes will also be deleted):
刪除一張表(表中的數(shù)據(jù)結(jié)構(gòu),屬性以及索引也會被刪除):
DROP TABLE table_name
To delete a database:
要刪除一個數(shù)據(jù)庫的話可以這樣寫:
DROP DATABASE database_name
--------------------------------------------------------------------------------
Truncate a Table
截表
What if we only want to get rid of the data inside a table, and not the table itself? Use the TRUNCATE TABLE command (deletes only the data inside the table):
當(dāng)我們只想將表內(nèi)的數(shù)據(jù)做完成清楚而保留其內(nèi)部結(jié)構(gòu)的話,可以使用TRUNCATE TABLE命令(僅僅刪除表中的數(shù)據(jù))
TRUNCATE TABLE table_name