oracle: 21C create user

 

1
2
3
4
5
6
7
8
9
10
11
--  oracle 21c
create user c##geovindu identified by 88888;
grant create session,create table,unlimited tablespace to c##geovindu;
 
create user c##geovin identified by 88888;
grant create session,create table,unlimited tablespace to c##geovin;
 
   
grant connect,resource,dba to c##geovindu;
   
grant connect,resource,dba to c##geovin;

  

 create table:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
drop table IF EXISTS School;
 
create table School  --創建表
(
    SchoolId char(5) NOT NULL-- 
    SchoolName nvarchar2(500) NOT NULL,
    SchoolTelNo  varchar(8)  NULL,       
  PRIMARY KEY (SchoolId)   --#主鍵
);
 
--对表的说明
comment on table School is '学校表';
--对表中列的说明
comment on column School.SchoolId is 'ID';
comment on column School.SchoolName is '名称';
comment on column School.SchoolTelNo is '电话号码';
 
select * from School order by SchoolId;

  

 客户端访问程序:

Oracle Instant Client Downloads

 

数据库建模:

https://www.oracle.com/database/sqldeveloper/technologies/sql-data-modeler/download/

 

 

 环境变量:(第一次写的好环境变量名称,重启电脑,名称写错了,不能重改,否则无法登录数据库,错了名称可以一样用) 这一步不需配置

ORACLE_HOME = D:\database\oracle\instantclient_21_15
TNS_ADMIN = D:\database\oracle\instantclient_21_15
NLS_LANG = SIMPLIFIED CHINESE_CHINA.ZHS16GBK
修改Path变量,在后面添加 D:\database\oracle\instantclient_21_15

不需要写配置文件

这个.net 配置也换了内容:

 

不配置是:

 

 create table:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
drop table IF EXISTS School;
  
create table School  --創建表
(
    SchoolId char(5) NOT NULL-- 
    SchoolName nvarchar2(500) NOT NULL,
    SchoolTelNo  varchar(8)  NULL,       
  PRIMARY KEY (SchoolId)   --#主鍵
);
  
--对表的说明
comment on table School is '学校表';
--对表中列的说明
comment on column School.SchoolId is 'ID';
comment on column School.SchoolName is '学校名称';
comment on column School.SchoolTelNo is '电话号码';
  
select * from School order by SchoolId;

  

python:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# encoding: utf-8
# 版权所有 2024 涂聚文有限公司
# 许可信息查看:言語成了邀功盡責的功臣,還需要行爲每日來值班嗎
# 描述:python -m pip install oracledb
# python -m pip install cx_Oracle --upgrade
# pip install cx_Oracle
# Author    : geovindu,Geovin Du 涂聚文.
# IDE       : PyCharm 2024.3 python 3.11
# os        : windows 10
# database  : mysql 9.0 sql server 2019, poostgreSQL 17.0 oracle 21c
# Datetime  : 2024/12/28 12:15
# User      : geovindu
# Product   : PyCharm
# Project   : Pysimple
# File      : oracledemo.py
# explain   : 学习
import getpass
import oracledb
import cx_Oracle
  
  
class SchoolInfo(object):
    """
    """
  
    def __init__(self):
        """
  
        """
        self.__idno = None
        self.__schoolname = None
        self.__schooltel = None
  
    @property
    def idno(self):
        """
        :return:
        """
        return self.__idno
  
    @idno.setter
    def idno(self, no: str):
        """
        :param no:
        :return:
        """
        self.__idno = no
  
    @property
    def schoolname(self):
        """
        :return:
        """
        return self.__schoolname
  
    @schoolname.setter
    def schoolname(self, name: str):
        """
        :param name:
        :return:
        """
        self.__schoolname = name
  
    @property
    def schooltel(self):
        """
        :return:
        """
        return self.__schooltel
  
    @schooltel.setter
    def schooltel(self, tel: str):
        """
        :param city:
        :return:
        """
        self.__schooltel = tel
  
  
# 连接到Oracle数据库
connection = cx_Oracle.connect(user="c##geovindu", password="888888", dsn="localhost/TechnologyGame")
  
# 创建游标
cursor = connection.cursor()
  
# 执行查询
cursor.execute("SELECT * FROM School order by SchoolId")
  
# 获取查询结果
result = cursor.fetchall()
  
# 打印查询结果
dt = []
# 打印查询结果
for idno, name, tel in result:
    # print(idno,name,tel)
    info = SchoolInfo()
    info.idno = idno
    info.schoolname = name
    info.schooltel = tel
    dt.append(info)
print("****************")
for dd in dt:
    print(dd.idno, dd.schoolname, dd.schooltel)

  

posted @   ®Geovin Du Dream Park™  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2021-12-28 sql: paging in SQL Server
2015-12-28 csharp: json to csharp
2014-12-28 csharp:Learn how to post JSON string to generic Handler using jQuery in ASP.Net C#.
2012-12-28 Csharp: listview control binding database from datatable
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示