首頁  >  文章  >  資料庫  >  mysql的基本指令介紹

mysql的基本指令介紹

不言
不言轉載
2018-10-24 17:42:062276瀏覽

這篇文章帶給大家的內容是關於mysql的基本指令介紹,有一定的參考價值,有需要的朋友可以參考一下,希望對你有幫助。

前端狗初學MySQL,記錄
1、使用者登入:

mysql -uroot -p

2、檢視資料庫:

show databases;

3、建立資料庫:

create database firstsql;

4、進入資料庫:

use firstsql

5、查看資料庫中的所有表:

show tables;

6、建立表:

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

設定ID作為主鍵, NAME的值不能為空,Age 的預設值為10,備註為資訊。
7、檢視表格結構

desc firstsql.student;

8、檢視表格建立資訊

show create table student;

9、檢視表格資料

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

10、插入資料

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

11、刪除資料

delete from student;
delete from student where ID='001';

12、修改資料

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

#

以上是mysql的基本指令介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:segmentfault.com。如有侵權,請聯絡admin@php.cn刪除