时间:2021-07-01 10:21:17 帮助过:22人阅读
下面开始动手创建一个库,步骤如下:
先创建一个库,命令:
#create database wu;

查看新建的库,命令:
#show databases;

使用wu这个数据库,在里面创建表,表名是test,命令:
#use wu;
# create table test (id int(3),name char (10));

创建表的格式:Create table 表名字(表栏名1 数据类型,表栏名2 数据类型.。。。)
查看下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 创建 删除 清空