mysql的基本语句操作

.mysql的自动递增字段 关键字 auto_increment
.mysql分页查取数据:select * from 表名 order by 列名 desc(asc) limit n,m;注:n为从第n条后取m条数据
.desc 表名 或 show columns from 表名 –》查询表的结构
.mysql中取得当前时间语句 select now();时间日期的格式化查询 select date_format(now(),’%Y-%m-%d %H:%i:%s’)

.获取表格中的行数 select count(name) from inf 在通过结果集的getInt(1)获得行数

mysql中改变表一列的字段语法:alter table 表名 change column eamil email varchar(40) not null;

通过表与表之间的外键关系查询表信息:
sql = “select u.* from orders o,user u where o.id=? and u.id=o.user_id”;
\s 显示当前数据库信息
向表中添加一个字段
alter table tablename add 字段 类型;
向表中修改一个字段类型
alter table tablename modify 字段 新类型;
向表中修改一个字段名
alter table tablename change 旧字段 新字段 类型;

向表中删除一个字段
alter table tablename drop字段;
修改表名
rename table tablename to tablename ;
查看表的字符集
Show create table tablename;
修改表的字符集
Alter table tablename character set utf8;
修改字段名
Alter table tablename change column 字段名 新 字段名 类型;

猜你喜欢

转载自blog.csdn.net/wellxielong/article/details/79122086