首页 > 数据库 > mysql教程 > MySQL新手入门指南--快速参考 (2)_MySQL

MySQL新手入门指南--快速参考 (2)_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-06-01 13:58:45
原创
853 人浏览过

二、MySQL使用导引

  1.运用MySQL建立新数据库

  在shell下运行:

  $>mysqladmin create database01

  Database "database01" created.

  2.启动MySQL

  在shell下运行:

  $>mysql

  Welcome to the MySQL monitor. Commands end with ; or g.

  Your MySQL connection id is 22 to server version: 3.21. 29a-gamma-debug

  Type 'help' for help.

  3.更换数据库

  mysql>use database01

  database changed.

  4.创建表

  mysql>create table table01 (field01 integer, field02 char(10));

  Query OK, 0 rows affected (0.00 sec)

  5.列出表清单

  mysql>show tables;

  Tables in database01

  Table01

  table02

  6.列出表中的字段清单

  mysql>show columns from table01;

  Field Type Null Key Default Extra

  field01 int(11) YES

  field02 char(10) YES

  7.表的数据填写

  插入数据

  mysql>insert into table01 (field01, field02) values (1, 'first');

  Query OK, 1 row affected (0.00 sec)

  8.字段的增加

  ...一次一个字段

  mysql>alter table table01 add column field03 char(20);

  Query OK, l row affected (0.04 sec)

  Records: 1 Duplicates: 0 Warnings: 0

  ...一次多个字段

  mysql>alter table table01 add column field04 date, add column field05 time;

  Query OK, l row affected (0.04 sec)

  Records: 1 Duplicates: 0 Warnings: 0

  注意:每一列都必须以"add column"重新开始。

  它运行了吗?让我们看看。

  mysql>select * from table01;

  field01 field02 field03 field04 field05
    1 first NULL NULL NULL

相关标签:
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
数据库数据
来自于 1970-01-01 08:00:00
0
0
0
数据库
来自于 1970-01-01 08:00:00
0
0
0
数据库文件导入
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板