当前位置:   article > 正文

达梦数据库基本操作命令_达梦数据库创建命令

达梦数据库创建命令
  1. #事先创建一个用户存放表空间的目录,便于下面创建表空间
  2. mkdir /opt/dmdbms/data/xTableSpace
  3. chown -R dmdba.dinstall /opt/dmdbms/data/xTableSpace
  4. #登录达梦数据库命令行
  5. cd /opt/dmdbms/bin
  6. ./disql #输入账号密码,默认的是SYSDBA/SYSDBA
  7. #创建表空间(事先建好目录,并给目录改权限)
  8. create tablespace "xTableSpace" datafile '/opt/dmdbms/data/xTableSpace/xTableSpace.dbf' size 128;
  9. #注:感觉表空间有点像k8s的namespace
  10. #创建用户
  11. 使用命令行方式创建用户 XUSER01 ,密码 “mypwd123456”,使用散列算法 SHA512 ,使用存储加密密钥为 “123456”,指定表空间为xTableSpace,索引表空间为 xTableSpace,授予 "DBA"、”PUBLIC” 和 “SOI” 权限。示例参考如下:
  12. create user "XUSER01" identified by "mypwd123456" hash with SHA512 salt encrypt by "123456" default tablespace "xTableSpace" default index tablespace "xTableSpace";
  13. grant "DBA","PUBLIC","SOI" to "XUSER01";
  14. #创建数据库对象:表
  15. 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);
  16. CREATE TABLE XUSER01.student
  17. (
  18. student_id INT NULL,
  19. student_name VARCHAR(50) NULL,
  20. student_gender VARCHAR(50) NULL,
  21. student_age INT NULL,
  22. student_address VARCHAR(100) NULL,
  23. );
  24. #插入测试数据,并提交(在什么环境下执行的命令,就得在什么环境下commit)
  25. INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(1,'serena',18,'huaian','female');
  26. INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(2,'kahn',19,'shanghai','male');
  27. INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(3,'fanbingbing',18,'anhui','female');
  28. INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(4,'liuyifei',18,'korea','female');
  29. INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(5,'liushishi',18,'hangzhou','female');
  30. INSERT INTO XUSER01.student(student_id,student_name,student_age,student_address,STUDENT_GENDER) VALUES(6,'yangchaoyue',18,'suzhou','female');
  31. commit;
  32. #删除一条数据
  33. DELETE XUSER01.STUDENT WHERE STUDENT_ID = 6;
  34. commit;
  35. #修改一条数据
  36. UPDATE XUSER01.STUDENT set student_age=20 WHERE student_id = 6;
  37. #创建一个视图
  38. CREATE VIEW XUSER01.v_female AS
  39. SELECT
  40. student_id,
  41. student_name,
  42. student_gender
  43. FROM
  44. XUSER01.STUDENT
  45. WHERE
  46. student_gender = 'female';
  47. #查看某个视图
  48. SELECT * from XUSER01.V_FEMALE;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/648101
推荐阅读
相关标签
  

闽ICP备14008679号