当前位置:Gxlcms > 数据库问题 > 基于linux操作系统Mysql的基本操作(二)

基于linux操作系统Mysql的基本操作(二)

时间:2021-07-01 10:21:17 帮助过:22人阅读

linux操作系统Mysql的基本操作(二)

下面开始动手创建一个库,步骤如下:

  • 先创建一个库,命令:

#create database wu

技术分享

  • 查看新建的库,命令

#show databases

技术分享

  • 使用wu这个数据库,在里面创建表,表名是test,命令:

#use wu

# create table test (id int(3),name char (10));

技术分享

创建表的格式:Create table 表名字(表栏名数据类型,表栏名数据类型.。。。)

  • 查看下test表,命令:

#show create table test

技术分享

  • test表格中增加内容,命令:

# insert into test values(1,teng);

# select * from test;

技术分享

只增加一个内容,命令:

# insert into test(id)values(2);

技术分享

  • 更新test表中的内容,命令:

# update test set name=‘fei‘ where id=2;

# select * from test;

技术分享

  • 删除表中的内容,命令:

# delete from test where id=2;

# select * from test;

技术分享

  • 清空表的内容,命令:

#truncate table test

技术分享

  • 删除表,命令:

#drop table test

技术分享

  • 删除库,命令:

#drop databases wu

技术分享

注:在删库和更新时,数据记得要备份!

本文出自 “吴腾飞” 博客,请务必保留此出处http://wutengfei.blog.51cto.com/10942117/1905963

基于linux操作系统Mysql的基本操作(二)

标签:linux mysql 创建 删除 清空

人气教程排行