With the familiarity of MySQL, this time to summarize the MySQL database delete, backup and restore operations
1. Deletion of the database:
A. Command to delete a database: Drop DB dbname;
B. Deleting a table from a database:
Single table: Drop TABLE tablename;
Multiple tables: Drop table tablename1,tablename2,tablename2; (Note that there are no fewer commas here, but when backing up multiple tables, there is no comma between multiple tables, which is written below)
C. Deleting records from a table: Delete;truncate table Two methods
Delete command: Delete from tablename (WHERE ..... LIMIT ....)
Can delete all records, or according to the criteria to choose to delete some of the data, the use of more flexible;
TRUNCATE command: TRUNCATE TABLE tablename;
Delete all records, cannot attach conditional clauses;
There is also a small difference: Delete can return the number of records deleted, TRUNCATE returns the number of records is 0 (the specific application of the two differences is not familiar with, and then after the familiar and then fill in)
2. Backup & Restore
Single database backup command: Mysqldump-u root-p dbname >/home/wuliang/dbname_backup.sql (dbname is the name of the database that needs to be backed up,/home/wuliang these are required for backup files Saved paths,. SQL backup files are stored in this format)
Table Backup in database: Mysqldump-u root-p dbname table1 table2 table3 >/home/wuliang/name_backup.sql (Note: There is no need to separate commas between multiple tables)
Multiple database backup commands: Mysqldump-u root-p--databases dbname1 dbname2 dbname3 >/home/wuliang/bcakup.sql (--databases to declare multiple databases)
Full database backup: Mysqldump-u root-p-all-databases >/home/wuliang/backup.sql (-all-databases to declare all databases)
Database restore: Mysql-u root-p
Welcome to files in database: Mysql-u root-p dbname
MySQL First knowledge 3