1. 创建表:
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
employee_name VARCHAR(255),
department_id INT
);
2. 创建索引:
CREATE INDEX idx_department ON employees (department_id);
3. 创建视图:
CREATE VIEW employee_view AS
SELECT employee_id, employee_name
FROM employees
WHERE department_id = 1;
4. 创建序列:
CREATE SEQUENCE employee_seq START WITH 100 INCREMENT BY 1;
5. 修改表结构(添加列):
ALTER TABLE employees
ADD COLUMN hire_date DATE;
6. 修改表结构(修改列类型):
ALTER TABLE employees
MODIFY COLUMN employee_name VARCHAR(100);
7. 删除表:
DROP TABLE employees;
8. 删除索引:
DROP INDEX idx_department ON employees;
9. 删除视图:
DROP VIEW employee_view;
10. 删除序列:
DROP SEQUENCE employee_seq;
这些语句提供了创建、修改和删除数据库对象的能力。请注意,实际使用时应谨慎操作 DDL 语句,特别是在生产环境中,以防止意外数据丢失或不可逆的变更。在执行 DDL 操作之前,最好备份数据或者在非生产环境中测试。
转载请注明出处:http://www.zyzy.cn/article/detail/11740/OceanBase