建立庫:
create database 庫名;建立帶編碼格式的庫:create database 庫名 character set 編碼格式;
刪除庫:drop database 庫名;建立表:
create table 表名(欄位1 型別1,欄位2 型別2,欄位3 型別3…);create table 表名(欄位1型別1,欄位2 型別2,欄位3 型別3…);
刪除表:drop database 表名;
增(insert):
第一種格式:insert into 表名 (欄位1,欄位2,欄位3,欄位4)values(值1,值2,值3,值4),(值1,值 2,值3,值4),。。。
第二種格式:insert into 表名 set 欄位1=值1,字段 2=值2,欄位3=值3。。。;
刪(delete):
delete from 表名 where 條件
such as :delete from 表名 where 學號=1;
改(update):
update 表名 set 欄位1=值1,欄位2=值2,欄位3=值3,。。。 where 條件
such as:delete 表名 set name='張三' where 學號='01';
查(select):
select * from 表名; 查詢表中所有資料
select 欄位1,欄位2,。。。 from 表名; 查詢表中指定字段值
select 欄位1 from 表名 where 條件; 查詢指定表中指定欄位的指定值
資料庫查詢語言(dql):select(1)show create database 庫名;資料庫定義語言(ddl):create database、drop database 、create table、drop table、alter
資料庫操作語言(dml):update 、insert 、delete
(2)show databases; 檢視mysql下所有的庫
(3)select database(); 檢視當前使用者鏈結的是那個資料庫
(4)desc 表名; 檢視表中的字段
(5)show create table 表名 檢視指定表的sql資訊
(6)rename table 舊表名 to 新錶名 對已經存在的表進行重新命名
(7)alter table 表名 add 欄位名 資料型別; 向已存在的表中新增字段資訊
(8) alter table 表名 drop 被刪除的欄位名; 刪除指定表中的指定字段
(9)alter table 表名 change 舊欄位名 新欄位名 新字段型別; 對錶中字段進行重新命名
mysql 的基本語法 MYSQL基本語法
資料庫 可視為電子化的檔案櫃 儲存電子檔案的處所 為什麼使用資料庫 持久化 方便管理資料 結構化查詢 非結構化查詢 net start 程式 啟動 net stop 程式 結束 mysql uroot p3307 p 新建資料庫 create database 資料庫名 使用資料庫 use 資料庫名...
mysql的基本語法 mysql的基本語法
正文本篇文章主要是記錄一些常用的mysql語法,方便使用時候進行查閱。linux上常用命令 命令都以 結尾 1,登入mysql mysql u賬號 p密碼 2,檢視幫助 help 或者 h 3,檢視有哪些資料庫 show databases 4,進入某個資料庫 use databasename 5,...
MySql基本語法
基本語法 create database 資料庫名 資料庫選項 字符集等 基本語法 匹配模式 show create database 資料庫名 use 資料庫名 修改庫選項 alter database 資料庫名 選項 值 基本語法 drop 資料庫名 基本語法 create table 表名 欄...