1.-命令行漓摩,進(jìn)入MYSQL數(shù)據(jù)庫
????mysql -u用戶名 -p密碼?
2.庫級命令
? ??1.顯示所有的庫:show databases;
·? ?2.創(chuàng)建庫:create database db_name;
? ? ? ? ? ? ? ? ? ? ?create database if not exists db_name; 如果存在會報錯
????3.刪除庫:drop datebase db_name;
? ? ? ? ? ? ? ? ? ? ? drop database if exists db_name;
????4.進(jìn)入數(shù)據(jù)庫:use db_name;
????????****** 數(shù)據(jù)庫名有大小寫之分
3.表級命令
? ??1.顯示所有的表:show tables;
????2.創(chuàng)建表:create table student (id int, name varchar(20), age int);
? ? 3.顯示創(chuàng)建信息:show create table tb_name;
? ? 4.刪除表:drop table if exists tb_name;
4.對表的操作
? ??1.指定字段插人:insert into student (name, age) values ('wuhongcheng', 18);
? ? 2.全字段插入:insert into student values (2,'xx', 19);
? ? 3.多行插入:insert into student values (2, 'name1', 16),(3, 'name2', 20);
? ? 4.刪除所有數(shù)據(jù):delete from student;?
????5.刪除指定數(shù)據(jù):delete from student where age=18;
? ? 6.修改一個字段的所有數(shù)據(jù):update student set name='m';
????7.修改多個字段的數(shù)據(jù): update student set id=1,age=22 where name='xxx';
? ? 8.修改滿足條件的數(shù)據(jù):update student set age=18 where id=2;
? ? 9.全字段查詢:select * from tb_name;
????10.指定字段查詢:select name, age from student;
????11.帶條件查詢:select * from student where age>17;