Home  >  Article  >  Database  >  Sharing of commonly used MySQL commands

Sharing of commonly used MySQL commands

黄舟
黄舟Original
2017-08-20 15:10:581287browse

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;

Enter:

mysql -u root -p/mysql -h localhost -u root -p databaseName;

List database:

show databases;

Select database:

use databaseName;

List table:

show tables;

Create data table:

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

Display the attributes of the table columns:

show columns from tableName;

Modify the structure of the table:

DESCRIBE mytable;

Create the database:

source fileName.txt;

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;

Add multiple fields:

alter table tabelName add column fieldName1 dateType,add columns fieldName2 dateType;

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

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

Query time:

select now( );

Query current user:

select user( );

Query database version :

select version( );

Query the currently used database:

select database( );

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!

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