Heim  >  Artikel  >  Datenbank  >  mysql常用操作_MySQL

mysql常用操作_MySQL

WBOY
WBOYOriginal
2016-06-01 13:43:271013Durchsuche

bitsCN.com

1、修改表名 在mysql中修改表名的sql语句在使用mysql时,经常遇到表名不符合规范或标准,但是表里已经有大量的数据了,如何保留数据,只更改表名呢? ALTER TABLE table_name RENAME TO new_table_name 例如 ALTER TABLE admin_user RENAME TO a_user

2、删除表 drop table shili ; 在删除数据表的过程中,如果删除一个不存在的表将会产生错误,这时在删除语句中加入IF EXISTS关键字,就可避免产生错误,具体格式如下: drop table if exists students ;

下边举例说明,如果想删除”wp_”开头的表: Select CONCAT( 'drop table ', table_name, ';' )FROM information_schema.tables Where table_name LIKE 'wp_%'; 这样就会出现drop table wp_xxxx 的所有语句,复制下来,简单修改一下,直接粘贴到命令行中运行就可以啦~~




作者 chen3888015 bitsCN.com
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn