mysql的一些简单语句

本文详细介绍了如何安装、卸载、登录、新建、使用、删除数据库,以及创建、删除表,添加、删除、修改字段等Mysql核心操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//安装Mysql
mysqld install
//卸载Mysql
mysqld remove
//登录Mysql
mysql -u root -p
//新建数据库
create database d_dname;
//使用数据库
use t_tname;
//查看数据库的属性
desc t_tname;
//删除数据库
drop d_dname;

//建一个表
create table if not exists t_user(
	id int(11) PRIMARY KEY AUTO_INCREMENT,
	userName varchar(20),
	nickName varchar(20),
	password varchar(30)
)

//查看表的属性
desc t_user;
//删除表
drop t_user;
//向数据库中添加一个字段
alter table t_user add address varchar(100);
//删除表中的某个字段
alter table t_user drop address;
//删除表中的某个字段
alter table t_user drop column address;
//修改字段的名
alter table t_user change nickName nk varchar(50);
//移动字段所在的位置
alter table t_user modify password varchar(30) after userName;


create table if not exists t_student(
	id int(11) primary key auto_increment,
	name varchar(50),
	no varchar(50) not null,
	born datetime
);

//导入外部的文本
source D:/mysql/create_table.sql

//修改密码的操作
grant all on *.* to 'root'@'localhost' identified by '123456'
//创建新的用户
grant all on itcast_test.* to 'itat'@'localhost' identified by 'itat123'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蟹道人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值