![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
IP: 114.238.136.93
|
|||
|
|||
|
mysql> \s 查看mysql服务器状态
mysql>exit 退出mysql mysql>show databases; 查看所有数据库 databases复数形式 mysql>create database abiao; 创建abiao数据库 database用单数形式 mysql>drop database abiao 删除abiao数据库 database用单数形式 mysql>create database if not exists xsphp; 如果xsphp数据库不存在就创建它 mysql>drop database if not exists xsphp; 如果xsphp数据库存在就删除它 mysql>create table abiao.users(id int,name char(30),age int,sex char(3));在abiao这个数据库下创建表users mysql>use abiao; 选择一个库作为默认的库,也是当前库 mysql>show tables;查看所有的表 mysql>desc users 查看users这个表的结构(如users这个表在的话) mysql>drop table if exists users 如果users表存在就删除它 mysql>create table users(id int,name char(30),age int,sex char(3));由于当前在xsphp这个数据库下,创建表users时就不要xsphp. mysql>create table if not exists users(id int,name char(30),age int,sex char(3)); mysql>insert into users values();()内的字段按顺序写,如: mysql>insert into users values(1, 'zhangsan', 10,'nan'); mysql>insert into users values('2', 'susan', '20','nv');注意:插入语句时, 字段的值全部按字符串的要求写,放在''中. mysql会自动转换 mysql>insert into users(id,name, age) values('3','jack','15'); 这样插入数据时, 可根据要求插入字段,也可不考虑字段的顺序. mysql>insert into users(age,name, id) values('25','steven','4'); 多个字段或值用,隔开 mysql>select * from users;查users表中所有记录 mysql>update users set name='stone' where id='2'; 将id为2的name设置为stone 修改字段中一个字段的值 mysql>update users set name='jane', age='29', sex='nv' where id='1; mysql>delete from users where id='2; 删除id为2的那条记录.注意如不加条件where就会删除整个表的 mysql>? content; 对内容分类进行帮助 要改成命令mysql>help contents; mysql>? data types; 查数据类型,也可用mysql>help data types; mysql>? int; 查看int类型的帮助,也可用mysql>help int; mysql>? show; 显示所有与show相关的命令 mysql>? create table查如何创建表结构 Server version: 5.5.16 MySQL Community Server (GPL) Protocal version: 10 Last edited by admin : 2014-11-19 at 08:48 AM |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|