Modifying an existing table to add TTL using the Java API:
HConnection connection = HBaseConnection.createConnection("localhost", "2181");
HBaseAdmin hBaseAdmin = new HBaseAdmin(connection);
HTableDescriptor hTableDescriptor = new HTableDescriptor("TTLDemo".getBytes());
HColumnDescriptor hColumnDescriptor = new HColumnDescriptor("C".getBytes());
hColumnDescriptor.setTimeToLive(2);
hTableDescriptor.addFamily(hColumnDescriptor);
hBaseAdmin.modifyTable("TTLDemo", hTableDescriptor);
source
share