Home > Database > navicat > How to use navicat for mysql command line operations?

How to use navicat for mysql command line operations?

angryTom
Release: 2019-08-07 15:20:01
Original
11457 people have browsed it

How to use navicat for mysql command line operations?

The following describes how to use Navicat to perform mysql command line operations.

Recommended tutorial: MySQL database introductory tutorial

1. Open Navicat

How to use navicat for mysql command line operations?

2. Click the [Tools] menu and select [Command Line Interface]

How to use navicat for mysql command line operations?

3. At this time, you have entered the mysql command line state

How to use navicat for mysql command line operations?

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 &#39;0&#39;,
> 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,&#39;Tom&#39;,96.45),(2,&#39;Joan&#39;,82.99), (2,&#39;Wang&#39;, 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 Data

For 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=&#39;Mary&#39; 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 &#39;0&#39;
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(&#39;    &#39;, 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!

Related labels:
source:php.cn
Statement of this 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template