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
2. View database:
show databases;
3. Create database:
create database firstsql;
4. Enter the database:
use firstsql
5. View all tables in the database:
show tables;
6. Create a table:
create table student( ID char(7) primary key, NAME varchar(20) not null, Age varchar(20) default '10' )comment='信息';
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;
8. View table creation information
show create table student;
9. View table data
select * from student; select ID,NAME,Age from Student; select * from Student where ID='001';
10. Insert data
insert into student values ('001','二哈','计算机');
11. Delete data
delete from student; delete from student where ID='001';
12. Modify data
update student set NAME='物联网' where ID='001';
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!