网络营销电子商务研究中心  
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 Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   IP: 49.87.98.13
Old 2014-11-20, 10:38 PM
Fentress Fentress is offline
初级会员
 
Join Date: 2008-09-21
Posts: 1
Fentress 现在声名狼藉
Default 数据表插入/修改/删除记录

create table cats(
id int not null auto_increment,
pid int not null default '0',
name varchar(60) not null default '',
desn text not null default '',
primary key(id),
index name(name,pid)
);


create table products(
id int not null auto_increment,
cid int not null default '0',
name varchar(60) not null default '',
price double(7,2) not null default '0.00',
num int not null default '0',
desn text,
ptime int not null default '0',
primary key(id),
key pname(name,price));


插入表数据 insert

insert into 表名([字段列表]) values(值列表)
mysql>insert into cats values(null,0,'soft','this is soft');

特点:
1. 如果在表名后没有给出字段列表,则值列表必须列出所有字段的值,必须按表中默认的顺序插入
2. 所有需要写字段的地方都不加单引号或双引号,但所有值建议都要以字符串的形式使用

mysql>select 1+1; 2
mysql>select 1+'1' 2

mysql>insert into cats values(null,'1','java','this is java');


3.建议在插入数据时,最好给出字段列表,则值要和字段列表对应即可
mysql>insert into cats (pid, name) values('1','php');
mysql>insert into cats(name,pid) values('c++','1');

可以一次插入多条记录
mysql>insert into cats(name,pid) values('j2se','2'),
->('j2me','2'),
->('j2ee','2'),
->('smarty','3'),
->('thinkphp','3')

update 表名 set 字段='值' [条件] 条件是确定要更改的记录,可以通过条件指定一条,也可以指定多条
delete from 表名[条件]
select
where 条件
都可以使用各种运算符(可以把字段当作一个变量来使用)
只要你想更新/删除/查找,只要写对条件就能准确找到要管理的一条或多条语句
mysql>update cats set pid='3' where id=8;
mysql>update cats set pid='2' where id>=5 && pid<=6;

truncate [英][trʌŋˈkeɪt] 截断

mysql>delete from cats where id>8; 删除id大于8的记录
Reply With Quote
 


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

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 07:28 AM.


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