mysql資料庫操作
mysql操作步驟:
- 在cmd中鏈接mysql服務器:
mysql -u root -p
entry password: 輸入密碼 - 當進入到mysql服務器中,可以查看有哪些資料庫
show databases; - 創建資料庫: create database 資料庫的名字;
- 進入資料庫: use 資料庫的名字;
- 查詢當前是在哪個資料庫: select database();
- 創建表結構-
create table 表名(
欄位1 欄位型別 [約束條件],
欄位2 欄位型別 [約束條件],
);
create table user(
id int not null primary key auto_increment,
name varchar(20) not null,
age int not null
);
- 查看當前資料庫中有哪些表: show tables;
- 查看表的結構:desc 表名;
- 增加表格內容:alter table 表名 add 內容
- 洗掉行:alter table 表名 drop 要洗掉那行中的第一個元素
- 改變表格中某個引數:alter table 表名 modify 內容(內容:不需要改變的物件照抄,需要改變的物件,直接填寫改變后的物件)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/169854.html
標籤:其他
上一篇:關系型資料庫(Relational Database)與非關系型資料庫(NoSQL)的區別:(MySQL,Redis,Memcache,MongoDB)
