表操作SQL(DDL语句)
其实个人觉得没必要去记这些语法,因为你业务里面很少会用多操作表,大多都是提前创建好表后去操作行,而图形化工具真的真的很强大!
1、创建表:
语法:create table 表名(字段名 数据类型......)
SQL> create table test(a varchar(255), b number); 表已创建。
2、增加表字段:
语法: alter table 表名 add 字段名 数据类型
SQL> alter table test add c date; 表已更改。
3、删除字段:
语法:alter table 表名 drop column 字段名
SQL> alter table test drop column b; 表已更改。
4、修改字段名:
语法:alter table 表名 rename column 字段名 to 新字段名
SQL> alter table test rename column c to b; 表已更改。
5、修改字段类型:
语法:alter table 表名 modify 字段名 数据类型
SQL> alter table test modify b number; 表已更改。
6、查看表结构:
语法:desc 表明
SQL> desc test; 名称 是否为空? 类型 ----------------------------------------- -------- -------------------------- A VARCHAR2(255) B NUMBER