Home > Database > Mysql Tutorial > Sharing of commonly used MySQL commands

Sharing of commonly used MySQL commands

黄舟
Release: 2017-08-20 15:10:58
Original
1321 people have browsed it

This article mainly introduces the knowledge points of MySQL for the Computer Level 2 Examination, and introduces commonly used MYSQL commands in detail, which has certain reference value. Interested friends can refer to

Computer Level 2 Examination MySQL Basics of knowledge points, commonly used MYSQL commands, as follows

Commonly used MYSQL commands (add computer secondary sites to favorites)

Start:

net start mySql;
Copy after login

Enter:

mysql -u root -p/mysql -h localhost -u root -p databaseName;
Copy after login

List database:

show databases;
Copy after login

Select database:

use databaseName;
Copy after login

List table:

show tables;
Copy after login

Create data table:

mysql> CREATE TABLE mytable (name VARCHAR(20), sex CHAR(1), 
  -> birth DATE, birthaddr VARCHAR(20));
Copy after login

Display the attributes of the table columns:

show columns from tableName;
Copy after login

Modify the structure of the table:

DESCRIBE mytable;
Copy after login

Create the database:

source fileName.txt;
Copy after login

Match characters: You can use the wildcard character _ to represent any character, and % to represent any String;

Add a field:

alter table tabelName add column fieldName dateType;
Copy after login

Add multiple fields:

alter table tabelName add column fieldName1 dateType,add columns fieldName2 dateType;
Copy after login

Multi-line command input: Be careful not to break words; when inserting or changing data , the field string cannot be expanded into multiple lines, otherwise the hard return will be stored in the data;

Add an administrator account:

grant all on *.* to user@localhost identified by "password";
Copy after login

After each statement is entered, Add a semicolon ';' at the end, or add '\g';

Query time:

select now( );
Copy after login

Query current user:

select user( );
Copy after login

Query database version :

select version( );
Copy after login

Query the currently used database:

select database( );
Copy after login

The above is the detailed content of Sharing of commonly used MySQL commands. 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