1、Mysql
1.列操作
增加列
ALTER TABLE testalter_tbl ADD i INT AFTER c;
修改列属性
ALTER TABLE testalter_tbl MODIFY c CHAR(10);
修改列默认值
ALTER TABLE testalter_tbl ALTER i SET DEFAULT 1000;
ALTER TABLE testalter_tbl ALTER i DROP DEFAULT;
2.sql
取分组第一
SELECT
max.*, MAX(max.line) lineMax
FROM
(
SELECT DISTINCT
(a.id) tt,
a.*
FROM
student a
ORDER BY
a.line DESC
) max
GROUP BY
student_id
2、Hive
1.修改表结构
1.重命名表
ALTER TABLE table_name RENAME TO new_table_name;
2.修改列
ALTER TABLE test_table CHANGE col1 col2 STRING COMMENT 'The datatype of col2 is STRING' AFTER col3;
3.增加列
ALTER TABLE employee ADD COLUMNS (dept STRING COMMENT 'Department name');
4.增加表属性
ALTER TABLE table_name SET TBLPEOPERTIES table_properties;
5.表注释
ALTER TABLE da.shop_recharge_serial_monthly SET TBLPROPERTIES ('comment' = '财务月结数据表')