chengzhongde

一、查询所有数据库

代码:show databases;

成功后如下图:

二、建立一个数据库

代码:create database test3;

成功后如下图:

三、连接数据库

代码:use test3;

成功后如下图:

 

四、建立库表

代码:create table test{

id int not null primary key auto_increment,

name varchar(30) not null

};

成功后显示:

 

 五、显示表结构

代码:desc test;

成功后显示:

六、添加表内容

代码:insert into test (`name`)values(\'test\');

成功后显示:

七、查询表内容

代码:select * from test;

成功后显示:

八、修改表内容

代码:update test set name = \'test2\';

成功后显示:

九、删除表内容

代码:delete from test;

成功后显示:

十、添加表字段

代码:alter table test add password varchar(30) not null;

成功后显示:

十一、修改表字段名

代码:alter table test change name username varchar(50) not null;

成功后显示:

 

 十二、修改表字段类型

代码:alter table test modify username char(30) not null;

成功后显示:

十三、删除表字段

代码:alter table test drop username;

成功后显示:

十四、删除数据库表

代码:drop table test;

成功后显示:

十五、删除数据库

代码:drop databases test3;

成功后显示:

十六:关闭数据库

代码:exit;

 成功后退出命令行关闭。

 

分类:

技术点:

相关文章:

  • 2021-06-30
  • 2021-06-08
  • 2021-04-10
  • 2021-05-29
  • 2022-12-23
  • 2021-07-24
  • 2021-04-23
猜你喜欢
  • 2021-05-13
  • 2022-01-28
  • 2022-01-15
  • 2021-07-30
  • 2021-04-01
  • 2021-08-24
相关资源
相似解决方案