注册 登录
编程论坛 J2EE论坛

关于mysql的数据库和表的相关操作

rongjing 发布于 2007-06-20 18:53, 594 次点击
为数据库授权:
grant all privileges on handbook.* to 'admin'@'localhost' identified by 'iamtheadmin' with grant option;
创建表:
create table t_search (search_key1 varchar(50), search_key2 varchar(50), unit_flag int unsigned, description_flag int unsigned, method_flag int unsigned, use_description varchar(200));

插入数据:
insert into linear_matrix values(98, 'pressure', 'PSI, mm of Hg', 'Convert pressure from PSI to mm of Hg.', 'LinearEquation', 'not used', 'PSI_unit', 0.20, 20.2, 'NO', 98, 'PSI', 'mm', 98);

添加自动编号字段:
alter table hjy add column id int unsigned not null auto_increment primary key;
增加字段:
alter table publisher add column catalog varchar(200);
修改字段:
alter table linear_matrix change constant(old name) constant2(new name) float;
删除字段:
alter table TableName DROP Field_name_tobe_delete

更新数据:
update linear_matrix set unit_flag2=5 where use_description='Convert temperature from C to F.';
删除记录:
delete from table_name where column_name='';


退出mysql:
quit
2 回复
#2
风月_无边2007-06-21 10:56
最好把你的教程传上来吧
#3
rongjing2007-06-21 11:26
我 这个是平时写程序时用到的,把常用的总结了下来,贴出来是因为一方面自己用到时可以方便查,另一方面也提供给那些需要的朋友。
1