庫:
show databases;顯示所有資料庫
create database <資料庫名> ;創建資料庫
use <資料庫名>;使用資料庫
drop <資料庫名> 直接刪除資料庫, 不提醒
show tables; 查看當前資料庫中的表
desc name ;顯示錶的詳細數據
select database;查看當前使用的資料庫
create database mysql;創建一個資料庫mysql
表:
create table <表名> ( <欄位名> <類型> [,..<欄位名n> <類型n>]);創建表
insert into <表名> (列1. 列2…列n) values (值1.值2… 值n);給表中插入數據
desc 表名,或者show columns from 表名;獲取表結構
select * from<表名>;查詢表中數據
rename table<原表名> to<新表名>;重新命名表
delete from <表名>; – 刪除這個表中所有記錄,但表的定義不動
delete from<表名> where 列名=條件; – 僅刪除符合條件的記錄
drop table <表名>; – 刪除這個表,連同裡面的數據
alter table<表名> add欄位 類型 其他;在表中增加欄位
update 表 set 列名=新值, 列2=值2 …; – 修改表中所有的行
update 表 set 列名=新值, 列2=值2 … where 列名=條件; – 僅更新符合條件的記錄
原創文章,作者:投稿專員,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/268189.html