Linux-mysql basic instructions-Adding and deleting changes

Source: Internet
Author: User

Common directives

instruction function

Instructions

View/Query

Show,select,desc

Create

Create

Delete

Drop,delete,truncate

Toggle/Enter

Use

Add a record

Insert

View the list of databases

show databases;

View current database The user logged in

Select User ();

See which tables are in the current database

Show tables;

To view the encoding type of the test database

Show create DATABASE test;

View the type of test table

Show create TABLE test;

View the definition information for the test table

DESC test;

Create a database

Create Database db1;

Create a database of type UTF8MB4

Create DATABASE DB2 DEFAULT CHARACTER SET UTF8MB4;

Create a table

CREATE TABLE students (ID int UNSIGNED not NULL PRIMARY key,name VARCHAR (a) not null,age tinyint UNSIGNED);

Add record for EMP table (with Id,name,sex,age field)

INSERT into EMP (id,name,sex,age) VALUES (1, ' xiaoming ', ' m ', 30);

Modify the contents of the EMP table (number of fields in the first few lines)

Update emp set age=18 where id=4;

Deleting a database

Drop database db1;

Delete Test table

DROP TABLE Test

Delete records in an EMP table

Delete from emp where name= ' Lvdou ';

Delete EMP entire table record

Delete from EMP;

Note: This command is slow to delete tens of thousands of records (because he logs, you can use the log to restore)

TRUNCATE TABLE emp; This command deletes tens of thousands of records, particularly quickly.

Because he doesn't record logs.

Empty the EMP table

TRUNCATE TABLE EMP;

Bulk Execute SQL Program

MySQL < Hellodb_innodb.sql

Note: You can also view the database without entering the database

Mysql-e ' Show databases '

Linux-mysql basic instructions-Adding and deleting changes

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.