课程作业
1.创建表,为表添加字段
drop table if exists test; create table test( id bigint, name varchar(50) not null, age int default 20, primary key(id) ); alter table test add column sex Boolean;

2.删除表中的已有字段
alter table test drop column sex ;
3.删除表的已有约束、添加约束
--执行下面的SQL语句,删除刚刚添加的列sex: alter table test drop column sex ; --执行下面gsql命令,再次查看表test的信息 \d test 删除表的已有约束 --表test上有一个名叫test_pkey的PRIMARY KEY约束。执行下面的SQL语句,删除这个约束: alter table test drop constraint test_pkey; --执行下面的gsql命令,再次查看表test的信息: \d test
4.修改表字段的默认值
alter table test alter column age set default 25; \d test
5.修改表字段的数据类型
alter table test ALTER COLUMN age TYPE bigint; \d test
6.修改表字段的名字
ALTER TABLE test RENAME COLUMN age TO stuage; \d test
7.修改表的名字
ALTER TABLE test RENAME TO mytest; \d mytest
8.删除表
DROP TABLE mytest;




