数据库_demo1
1.模式
- 权限:
获取数据库管理员权限的用户或者拥有管理员赋予的创建模式的权限的用户能创建模式
- 创建语法格式
modeName为模式名(不写默认为用户名), username指定该模式创建的对象
create schema "modeName" authorization username;
讯享网 - 本质:
创建了一个命名空间
2.基本语法
- 数据库
- 创建
讯享网
create database ss;- 删除
drop database ss; - 表
- 指定数据库
讯享网
use ss; - 创建
create table tb_demo1( name1 varchar(12), age1 int ); create table tb_demo2( name2 varchar(13), age2 int );- 增加
讯享网
-- 添加值 insert into tb_demo1(name,age) values('lihua', 12); -- 添加列 alter table tb_demo1 add column new_column varchar(12); -- 添加主键约束 alter table tb_demo1 add constraint name1 primary key tb_demo1(name1); alter table tb_demo1 add constraint name1 primary key tb_demo2(name2); -- 添加唯一性约束 -- 唯一约束:可以在一个字段,一组字段或一个表上定义唯一性约束,保证值不相同 alter table tb_demo1 add constraint name1 unique (name1); alter table tb_demo1 add constraint name1 unique tb_demo1(name1); alter table tb_demo1 add constraint name1 unique tb_demo2(name2); -- 添加检查约束(约束值的范围) alter table sss add constraint age check(age > 0 and age < 40); - 删除
-- 删除表 drop table tb_demo1; -- 删除列 alter table tb_demo1
- 指定数据库

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/71579.html