数据库——demo1(sql基本操作)

数据库——demo1(sql基本操作)数据库 demo1 1 模式 权限 获取数据库管理员权限的用户或者拥有管理员赋予的创建模式的权限的用户能创建模式 创建语法格式 modeName 为模式名 不写默认为用户名 username 指定该模式创建的对象 create schema modeName authorizatio username 本质

大家好,我是讯享网,很高兴认识大家。

数据库_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 
小讯
上一篇 2025-01-28 20:58
下一篇 2025-03-13 18:12

相关推荐

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