學習二 MySql資料庫的基本操作

2021-07-10 23:12:39 字數 1702 閱讀 7648

標籤(空格分隔): mysql

net start

"mysql"

- 停止mysql服務

net stop mysql
mysql -h localhost -u root -p
create

database my_school; //建立資料庫

show databases; //顯示資料庫

drop

database my_school; //刪除資料庫

create

database school;

use school;

create

table student(

name varchar(20) not

null comment '姓名',

sid int(10) not

null

primary

key,

major varchar(50) not

null

default

'電器工程與自動化',

tel varchar(11) not

null

unique

key,

birthday date

notnull

);

show tables from school;  //檢視資料庫下面的所有表

show columns from student from school; //檢視某個表的具體列的資訊

describe school.student; //檢視某個表的資訊

describe school.student name; //檢視某個表的某個欄位的資訊

use school;

alter

table student rename new_student; //重新命名表的名稱

alter

table school.new_student change name new_name varchar(20) not

null;//修改表的某個欄位的名稱

alter

table school.new_student change new_name new_name varchar(40);//修改表的某個欄位的資料型別

alter

table school.new_student change major major varchar(50) not

null

default

'電腦科學';//修改表的某個欄位的預設值

alter

table school.new_student add email varchar(50) not

null comment '郵箱';//新增乙個新的字段

alter

table school.new_student drop email;//刪除乙個字段

drop

table

ifexists school.new_student;

mysql 格式整理 MySQL資料庫基本操作整理

儲存資料 insert into 表名 values 字段值,字段值,指定字段插入 insert into 表名 欄位名 values 字段值 查詢資料 select from 表名 where 條件 修改資料 update 表名 set 欄位名 字段值,欄位名 字段值,where 條件 刪除資料 ...

mysql資料庫前端操作 MySQL基本操作

mysql 常用操作 1.連線資料庫 mysql h 192.168.0.3 uroot p123456 2.建立資料庫 表 create database test db default charset utf8mb4 檢視建庫語句 show create database test db use...

MySQL學習(二) 資料庫的基本查詢

最基本的查詢語句是由select和from 關鍵字組成的select from t emp 查詢t emp表下所有 select empno,ename from t emp 查詢t emp表下empno,enameselect語句遮蔽了物理層的操作,使用者不必關心資料的真實儲存,交由資料庫高效的查...