Home > Database > Mysql Tutorial > body text

Introduction to basic commands of mysql

不言
Release: 2018-10-24 17:42:06
forward
2312 people have browsed it

This article brings you an introduction to the basic commands of mysql. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Front-end dog is new to MySQL, record it
1. User login:

mysql -uroot -p
Copy after login

2. View database:

show databases;
Copy after login

3. Create database:

create database firstsql;
Copy after login

4. Enter the database:

use firstsql
Copy after login

5. View all tables in the database:

show tables;
Copy after login

6. Create a table:

create table student(
  ID char(7) primary key,
  NAME varchar(20) not null,
  Age varchar(20) default '10'
)comment='信息';
Copy after login

Set ID as the primary key. The value of NAME cannot be empty, the default value of Age is 10, and the comment is information.
7. View table structure

desc firstsql.student;
Copy after login

8. View table creation information

show create table student;
Copy after login

9. View table data

select * from student;
select ID,NAME,Age from Student;
select * from Student where ID='001';
Copy after login

10. Insert data

insert into student values ('001','二哈','计算机');
Copy after login

11. Delete data

delete from student;
delete from student where ID='001';
Copy after login

12. Modify data

update student set NAME='物联网' where ID='001';
Copy after login

The above is the detailed content of Introduction to basic commands of mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!