SQL随笔
多表分页查询:
select p.* from category c ,categorysecond cs , product p where c.cid = cs.cid and cs.csid = p.csid and c.cid = 2 order by pdate desc limit 0,2;
向表中插入新的字段:
ALTER TABLE `Table_name` ADD COLUMN `Column_name` VARCHAR(15) NOT NULL DEFAULT '' AFTER `id`;
更新表数据:
UPDATE [LOW_PRIORITY] [IGNORE] table_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition]
查询所有的表信息:
select * from sysibm.systables AS s where type = 'T' and creator = 'DB2USER' ORDER BY s.NAME
复制数据库:
mysqldump olddb -u root -p**** --add-drop-table | mysql newdb -u root -p****
复制数据库至远程:
mysqldump olddb -uroot -p**** --add-drop-table | mysql -h 192.168.1.22 newdb -u root -p****