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

How to use navicat for mysql command line operations?

angryTom
angryTomOriginal
2019-08-07 15:20:0111344browse

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)

Create database

mysql> create database test;

Connect to the database

mysql> use test;

View the currently used database

mysql> select database();

Table information contained in the current database

mysql> show tables; (注意:最后有个 s)

Delete database
##

mysql> drop database test;

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));

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;

Delete table

Command :

drop table

For example: Delete the table named MyClass


mysql> drop table MyClass;

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);

Query the data in the table

Query all rows

mysql> select * from MyClass;

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;

or

mysql> select * from MyClass limit 0,2;

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;

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;

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;

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;

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);

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!

Statement:
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
Previous article:navicat 1366 errorNext article:navicat 1366 error