当前位置:首页 > 数据库 > mysql切换数据库命令

mysql切换数据库命令

show databases; 显示所有已经存在的数据库

create database test; 创建名字为test的数据库

drop database test; 删除名字为test的数据库

use test;使用名字为test的数据库

show tables; 显示这个数据库中的所有数据表

create table player(id int not null auto_increment primary key,name varchar(16) not null,level int not null default “0”,fightingValue int not null default “5”);创建一个名字为player的表,表里一共三列属性id,name,level,fightingValue;

describe player; 显示player这张表的属性

select * from player 遍历这张表的所有数据

insert into player (id,name,level,fightingValue)values (1,”法师”,1,10);增加一行数据

select name from player where id = 2; (查询player这张表中id 为 2 这一行的名字信息)

select * from player order by level asc;对player这张表按等级排序(正序)

select * from player order by fightingValue desc;对player这张表按战斗力排序(倒序)

delete from player where id = 1;删除player这张表中的id = 1的一行数据

update player set fightingValue = 50 where id = 1;更新player这张表中id为1的玩家的战斗力为50;

alter table player add column vipLevel int not null default “0”;增加player表中的一个vipLevel字段,类型为int;

alter table player drop vipLevel;删除player表中的vipLevel字段

alter table player rename as player1;将player这张表的名字改为player1;

mySql支持的常用数据类型:

tinyint,int,varchar,char,float,double

作者:天盗盗
来源链接:https://blog.csdn.net/weixin_34007888/article/details/113126206


版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaclub.cn/database/68424.html

分享给朋友: