mysql資料庫基本操作語句

2022-08-02 21:00:18 字數 779 閱讀 1364

1 更改欄位名:change

alter table student change column gradenews grade int(11);

2 增加欄位和刪除字段

alter table  student add column salary int(30) default 900000;

alter table student drop column salary;

alter table student add column ages  varchar(20) not null;

alter table student drop column ages

3 修改欄位的長度:modify

alter table student modify id int(20);

4 批量增加字段

alter table student add (age1 varchar(20), ids int(17), num int(34) default 7546123);

或者使用事務的方式:事務需要commit;

5 批量修改欄位的名稱:change

alter table student change s11 s111 int(7), change s12 s112 int(8) default 2019;

6 查詢某年級的人數

select count(1) from student where grade = 5;

select count(*) from student where grade = 5;

mysql資料庫操作的基本語句

1.運算元據庫 create database score default charset utf8 建立資料庫 use score 使用score資料庫 show databases 查詢資料庫 drop database score 刪除資料庫 show create database scor...

MYSQL資料庫基本語句

sqlite3支援的型別 整數,文字,浮點,二進位制 sqlite3 test.sqlite test.sqlite是資料庫的名字 table 檢視資料庫中是否有表 建立表 no學號 整型 主鍵 自動增長的 不能為空 name姓名 文字 不能為空 age年齡 整型 create table stud...

MySQL對資料庫的基本操作語句

前言 學習sql server已經兩年了,在學的時候覺得還不錯,但是在這接近兩年的時候中對於資料庫的操作大多只是簡單的增刪改查,很多東西都慢慢遺忘了,因為現在需要使用mysql,所以就再對sql進行乙個學習,並將其學習經歷記錄下來 建立資料庫 create database db name 建立資料...