MySQL數據庫應用

創建數據庫
create database wangmomo default charset utf8;
刪除數據庫
drop database if exists wangmomo;
查看數據庫
show databases;
使用數據庫
use database;
創建表
create table student (id int auto_increment, s_name varchar(10) not null, primary key(id))
刪除表
drop table student;
查看錶
show tables;查看當前有哪些表
查詢student表裏的所有信息
select * from student;
查詢student表裏的指定的某一條信息
select * from student where id=2;
查詢student 表裏的指定的前1,2條信息
select * from student where id in (1, 2);
查詢student表裏的——–
select * from student limit 2;

select * from student limit 1 offset 1;
把student表按照順序排列
select * from student order by(id);
把student表按照倒序排列
select * from student order by(id);
插入學生的名字和電話號碼
insert into student(id ,s_name, s_tel) values (‘李逵’, ‘15878451258’);
查看錶結構
desc student

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章