网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

Reply
 
Thread Tools Display Modes
  #1   IP: 114.238.136.93
Old 2014-11-18, 11:22 PM
Acadia Parish Acadia Parish is offline
初级会员
 
Join Date: 2011-01-15
Posts: 1
Acadia Parish 现在声名狼藉
Default MySQL数据库的基本操作入门

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
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 03:47 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.