waid 发表于 2018-10-10 09:35:47

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

  基于linux操作系统Mysql的基本操作(二)
  下面开始动手创建一个库,步骤如下:

[*]  先创建一个库,命令:
  #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>  # select * from test;


[*]  删除表中的内容,命令:

  # delete from test where>  # select * from test;


[*]  清空表的内容,命令:
  #truncate table test;


[*]  删除表,命令:
  #drop table test;


[*]  删除库,命令:
  #drop database wu;

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

页: [1]
查看完整版本: 基于linux操作系统Mysql的基本操作(二)