MySql command line client command Series Analysis

Source: Internet
Author: User
Tags mysql command line


1. Start and Exit 1. Enter MySQL: Start MySQL Command Line Client (DOS interface of MySQL) and enter the password for installation. At this time, the prompt is: mysql & gt; 2. exit MySQL: quit or exit 2. database operation 1. create database Command: create database for example: create a database named xhkdb mysql> create database xhkdb; 2. Display All database commands: show databases (Note: There is finally s) mysql> show databases; 3. delete database command: drop database For example: delete database mysql> drop database xhkdb; 4. Connect database command: use for example: if the xhkdb database exists, try to access it: mysql> use xhkdb; www.2cto.com screen prompt: Database changed 5. currently selected (connected) database mysql> select Database (); 6. Table information contained in the current database: Mysql> show tables; (Note: There is a last s) 3. Perform table operations. before the operation, connect to a database. 1. Run the table creation command: create table ([,...]); mysql> create table 'testa '(-> 'id' int (10) unsigned not null AUTO_INCREMENT,-> 'name' varchar (20) default null, -> primary key ('id') www.2cto.com->) ENGINE = MyISAM AUTO_INCREMENT = 65 default charset = utf8; 2. Table Structure command: desc table name, or show columns from table name mysql> DESCRIBE MyClass mysql> desc MyClass; mysql> show colum Ns from MyClass; 3. Delete table command: drop table example: delete a table named MyClass mysql> drop table MyClass; 4. insert Data command: insert into [([,...])] values (value 1) [, (value n)] 5. query the data in the table 1). query all rows. mysql> select * from MyClass; 2) mysql> select * from MyClass order by id limit; www.2cto.com 6. delete table data command: delete from table name where expression example: delete mysql> delete from MyClass where id = 1; 7. Modify Table data: update table name set field = new value ,... Where condition mysql> update MyClass set name = "Mary" where id = 1; 8. add a field to the table: Command: alter table name add field type other; for example: A passtest field is added to the MyClass table and the type is int (4). The default value is 0 mysql> alter table MyClass add passtest int (4) default "0" 9. Change table name: Command: rename table original table name to new table name; for example, in the table MyClass name changed to YouClass mysql> rename table MyClass to YouClass; Author: crystalwiner

Related Article

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.