mysql数据库初学者简单操作

mysql数据库操作

mysql操作步骤:

  • 在cmd中链接mysql服务器:
    mysql -u root -p
    entry password: 输入密码
  • 当进入到mysql服务器中,可以查看有哪些数据库
    show databases;
  • 创建数据库: create database 数据库的名字;
  • 进入数据库: use 数据库的名字;
  • 查询当前是在哪个数据库: select database();
  • 创建表结构-
create table 表名(
    字段1 字段类型 [约束条件],
    字段2 字段类型 [约束条件]);
create table user(
    id int not null primary key auto_increment,
    name varchar(20) not null,
    age int not null
);
  • 查看当前数据库中有哪些表: show tables;
  • 查看表的结构:desc 表名;
  • 增加表格内容:alter table 表名 add 内容
  • 删除行:alter table 表名 drop 要删除那行中的第一个元素
  • 改变表格中某个参数:alter table 表名 modify 内容(内容:不需要改变的对象照抄,需要改变的对象,直接填写改变后的对象)

猜你喜欢

转载自blog.csdn.net/weixin_49757981/article/details/109008095