2. Click the [Tools] menu and select [Command Line Interface]
3. At this time, you have entered the mysql command line state
Extended information: MySQL basic operation commands
Database operation
Show all databases
mysql> show databases;(注意:最后有个 s)
Copy after login
Create database
mysql> create database test;
Copy after login
Connect to the database
mysql> use test;
Copy after login
View the currently used database
mysql> select database();
Copy after login
Table information contained in the current database
mysql> show tables; (注意:最后有个 s)
Copy after login
Delete database ##
mysql> drop database test;
Copy after login
Table operation
Note: Use "use " before operation to connect to a database.
Create table
Command:
create table
( [,..< ;Field namen> ]);Example:
mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));
Copy after login
Get table structure
Command :
desc table name, or show columns from table name
Example:
mysql> describe MyClass
mysql> desc MyClass;
mysql> show columns from MyClass;
Copy after login
Delete table
Command :
drop table
For example: Delete the table named MyClass
mysql> drop table MyClass;
Copy after login
Insert data
Command:
insert into
[( [,.. ])] values ( value 1 )[, ( value n ) ]Example:
mysql> insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);
Copy after login
Query the data in the table
Query all rows
mysql> select * from MyClass;
Copy after login
Query the first few rows DataFor example: View the first 2 rows of data in the table MyClass
mysql> select * from MyClass order by id limit 0,2;
Copy after login
or
mysql> select * from MyClass limit 0,2;
Copy after login
Delete the data in the table
Command:
delete from table name where expression
For example: delete the record numbered 1 in the table MyClass
mysql> delete from MyClass where id=1;
Copy after login
Modify the data in the table
Command:
update table name set field=new value,...where condition
mysql> update MyClass set name='Mary' where id=1;
Copy after login
Add fields in the table
Command :
alter table table name add field type other;
For example: a field passtest is added to the table MyClass, the type is int(4), the default value is 0
mysql> alter table MyClass add passtest int(4) default '0'
Copy after login
Change table name
Command:
rename table original table name to new table name;
For example: change the name of table MyClass to YouClass
mysql> rename table MyClass to YouClass;
Copy after login
Update field content
Command:
update table name set field name = new content
update table Name set field name = replace(field name, 'old content', 'new content');
For example: add 4 spaces in front of the article
update article set content=concat(' ', content);
Copy after login
The above is the detailed content of How to use navicat for mysql command line operations?. For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn