alter table

表重命名

  1. alter table t1 rename to t2;

添加分区

  1. alter table t1 add if not exists partition(xx=yy) location ‘/xx‘;

添加多个分区

  1. alter table t1 add if not exists 
  2. partition(x1=y1) location ‘/x1‘
  3. partition(x2=y2) location ‘/x2‘
  4. partition(x3=y3) location ‘/x3‘;

修改分区

  1. alter table t1 partition(xx=yy) set location ‘/xx‘;

删除分区

  1. alter table t1 drop if exists partitioin(xx=yy);

添加列

  1. alter table t1 add columns(id int, name string);

修改列

  1. alter table t1 change column id id2 int comment ‘‘;

删除或者替换列

  1. alter table t1 replace columns(id int comment ‘‘, name string comment‘‘);

修改表属性

  1. alter table t1 set tblproperties(‘k1‘=‘v1‘);

修改表存储属性

  1. alter table t1 set fileformat sequencefile;
  2. alter table t1 partition(x=y) set fileformat sequencefile;
  3. alter table t1 set serde ‘xx.serde1‘ with serdeproperties(‘k1‘=‘v1‘);
  4. alter table t1 set serdeproperties(‘k1‘=‘v1‘);
  5. alter table t1 clustered by (id, name) sorted by (name) into 48 buckets;

归档分区

  1. alter table t1 archive partition(year=2014);
  2. alter table t1 unarchive partition(year=2014);

设置表是否可被删除

  1. alter table t1 enable no_drop;
  2. alter table t1 disable no_drop;
  3. alter table t1 partition(x=y) enable no_drop;

设置表是否可被查询

  1. alter table t1 enable offline;
  2. alter table t1 disable offline;

来自为知笔记(Wiz)

时间: 2024-10-29 10:39:55

alter table的相关文章

Laravel 5.4 migrate报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `us ers_email_unique`(`email`))

Laravel 5.4 migrate报错:Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `us     ers_email_unique`(`email`)) public function up() { Schema::create('users', function (Blu

mysql alter table

准备: create table t(x int,y int); 用法 1: 修改列的数据类 alter table t modify column y nvarchar(32); 用法2: 给表加一列 alter table t add column z int; 用法3: 删除表中的列 alter table t drop column z; 用法4: 给列改一个名字 alter table t change column y w int;这家伙要特别说明一下,它可牛逼了不只是可以改列名,还

[Hive - LanguageManual] Alter Table/Partition/Column

Alter Table/Partition/Column Alter Table Rename Table Alter Table Properties Alter Table Comment Add SerDe Properties Alter Table Storage Properties Additional Alter Table Statements Alter Partition Add Partitions Dynamic Partitions Rename Partition

MSSql Server 索引'uq_f_userName' 依赖于 列'f_userName'。由于一个或多个对象访问此列,ALTER TABLE ALTER COLUMN f_userName 失败

--需求有变,需要往t_login表的f_userName字段添加外国人名,之前设置的varchar(10)不够,商议决定改成varchar(30),执行的时候,提示消息 索引'uq_f_userName' 依赖于 列'f_userName'.由于一个或多个对象访问此列,ALTER TABLE ALTER COLUMN f_userName 失败.--原来,之前为了防止f_userName重复,添加了唯一索引uq_f_userName.--进行如下操作后,问题妥妥解决--表名:t_login(登

ALTER table t_shift_use modify phone BIGINT(20)

ALTER table t_shift_use  modify phone BIGINT(20) http://blog.csdn.net/hupanfeng/article/details/21454847 http://www.360doc.com/content/14/0823/22/19020299_404154334.shtml

修改数据库字段类型(alter table alter column)

MySQL: ALTER TABLE Customer MODIFY Address char(100); Oracle: ALTER TABLE Customer MODIFY Address char(100); SQL Server: ALTER TABLE Customer ALTER COLUMN Address char(100); ref: SQL Modify Column Syntax

【总结】alter table *** add constraint *** 用法

1. 主键约束 要对一个列加主键约束的话,这列就必须要满足的条件就是非空.因为主键约束:就是对一个列进行了约束,约束为(非空.不重复). [格式]alter table 表格名称 add constraint 约束名称 增加的约束类型 (列名) 例子:要对一个列加主键,列名为id,表名为emp alter table emp add constraint ppp primary key (id) 2. check约束就是给一列的数据进行了限制 [格式]alter table 表名称 add co

Hive - Create Table&Drop Table & ALTER Table(中)

译注:书接上篇,了解过创建表以及load data后,假如发现需要更改表字段类型或者添加表字段,怎么办?这篇文章将进一步了解具体细节. This chapter explains how to alter the attributes of a table such as changing its table name, changing column names, adding columns, and deleting or replacing columns. Alter Table St

ALTER TABLE causes auto_increment resulting key 'PRIMARY'

修改表为主键的自动增长值时,报出以下错误:mysql> ALTER TABLE YOON CHANGE COLUMN id id INT(11) NOT NULL AUTO_INCREMENT ADD PRIMARY KEY (id);ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the rig

遇到ORA-14047: ALTER TABLE|INDEX RENAME may not be combined with other operations错误

[[email protected] ~]$ sqlplus lc0029999/aaaaaa SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 10 00:11:32 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit