赞
踩
- #事先创建一个用户存放表空间的目录,便于下面创建表空间
- mkdir /opt/dmdbms/data/xTableSpace
- chown -R dmdba.dinstall /opt/dmdbms/data/xTableSpace
-
-
- #登录达梦数据库命令行
- cd /opt/dmdbms/bin
- ./disql #输入账号密码,默认的是SYSDBA/SYSDBA
-
-
- #创建表空间(事先建好目录,并给目录改权限)
- create tablespace "xTableSpace" datafile '/opt/dmdbms/data/xTableSpace/xTableSpace.dbf' size 128;
- #注:感觉表空间有点像k8s的namespace
-
- #创建用户
- 使用命令行方式创建用户 XUSER01 ,密码 “mypwd123456”,使用散列算法 SHA512 ,使用存储加密密钥为 “123456”,指定表空间为xTableSpace,索引表空间为 xTableSpace,授予 "DBA"、”PUBLIC” 和 “SOI” 权限。示例参考如下:
- create user "XUSER01" identified by "mypwd123456" hash with SHA512 salt encrypt by "123456" default tablespace "xTableSpace" default index tablespace "xTableSpace";
- grant "DBA","PUBLIC","SOI" to "XUSER01";
-
-
- #创建数据库对象:表
- CREATE TABLE XUSER01.student (student_id INT NULL, student_name VARCHAR(50) NULL,student_gender VARCHAR(50) NULL, student_age INT NULL, student_address VARCHAR(100) NULL);
- 或
- CREATE TABLE XUSER01.student
- (
- student_id INT NULL,
- student_name VARCHAR(50) NULL,
- student_gender VARCHAR(50) NULL,
- student_age INT NULL,
- student_address VARCHAR(100) NULL,
- );
-
- #插入测试数据,并提交(在什么环境下执行的命令,就得在什么环境下commit)
- INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(1,'serena',18,'huaian','female');
- INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(2,'kahn',19,'shanghai','male');
- INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(3,'fanbingbing',18,'anhui','female');
- INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(4,'liuyifei',18,'korea','female');
- INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(5,'liushishi',18,'hangzhou','female');
- INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(6,'yangchaoyue',18,'suzhou','female');
- commit;
-
-
- #删除一条数据
- DELETE XUSER01.STUDENT WHERE STUDENT_ID = 6;
- commit;
-
- #修改一条数据
- UPDATE XUSER01.STUDENT set student_age=20 WHERE student_id = 6;
-
-
- #创建一个视图
- CREATE VIEW XUSER01.v_female AS
- SELECT
- student_id,
- student_name,
- student_gender
- FROM
- XUSER01.STUDENT
- WHERE
- student_gender = 'female';
-
- #查看某个视图
- SELECT * from XUSER01.V_FEMALE;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。