sql語句大全(詳細)

2021-09-03 02:52:53 字數 868 閱讀 5005

檢視所有資料庫

show databases;
檢視當前使用的資料庫

select database();
建立資料庫

create databases 資料庫名 charset=utf8;
5.刪除資料庫

drop database 資料庫名
6 .使用資料句庫

use database 資料庫名
7.檢視資料庫中所有表

show tables;
1.檢視表結構

desc 表名
2.建立表結構的語法

create table table_name(

欄位名 資料型別 可選的約束條件);

demo:建立班級和學生表

create table classes(

id int unsigned auto_increment primary key not null,

name varchar(10)

);

create table students(

id int unsigned primary key auto_increment not null,

name varchar(20) default '',

age tinyint unsigned default 0,

height decimal(5,2

《SQL語句大全》

語 句 功 能 資料操作 select 從資料庫表中檢索資料行和列 insert 向資料庫表新增新資料行 delete 從資料庫表中刪除資料行 update 更新資料庫表中的資料 資料定義 create table 建立乙個資料庫表 drop table 從資料庫中刪除表 alter table 修...

SQL語句大全

建表 create table tab1 id counter,name string,age integer,date datetime 技巧 自增字段用 counter 宣告.欄位名為關鍵字的字段用方括號括起來,數字作為欄位名也可行.建立索引 下面的語句在tab1的date列上建立可重複索引 c...

習SQL語句之SQL語句大全

語 句 功 能 資料操作 select 從資料庫表中檢索資料行和列 insert 向資料庫表新增新資料行 delete 從資料庫表中刪除資料行 update 更新資料庫表中的資料 資料定義 create table 建立乙個資料庫表 drop table 從資料庫中刪除表 alter table 修...