在windows下安装了oracle,之后还需要下载64位的instantclient(https://download.oracle.com/otn_software/nt/instantclient/19300/instantclient-basic-windows.x64-19.3.0.0.0dbru.zip),解压后把这个的解压后的目录放在Path环境变量中。
11g对应的django只能是1.11以及之下!!!!!!!!!!!!cx_Oracle 7不行!!!!!!换6就可以了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
之后要安装cx_Oracle库
oracle的sql的记录查看&oracle的创建用户:
1 | select * from (select SQL_TEXT, FIRST_LOAD_TIME from v$sql order by FIRST_LOAD_TIME desc) where rownum<=10; |
数据库database默认有一个orcl(最后一个是小写字母l,不是大写的I也不是1),可以通过select name from v$database;
查看。
创建的用户默认就是这个数据库的,可以通过
1 | SELECT |
查看所有的表。
之后可以drop table xxx来删除表,但是数据库不能这么删除。
cx_oracle版本问题导致:
···
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “manage.py”, line 22, in
execute_from_command_line(sys.argv)
File “G:\django_test_oracle\venv\lib\site-packages\django\core\management_init_.py”, line 364, in execute_from_command_line
utility.execute()
File “G:\django_test_oracle\venv\lib\site-packages\django\core\management_init_.py”, line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “G:\django_test_oracle\venv\lib\site-packages\django\core\management\base.py”, line 283, in run_from_argv
self.execute(*args, **cmd_options)
File “G:\django_test_oracle\venv\lib\site-packages\django\core\management\base.py”, line 330, in execute
output = self.handle(*args, **options)
File “G:\django_test_oracle\venv\lib\site-packages\django\core\management\commands\migrate.py”, line 204, in handle
fake_initial=fake_initial,
File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\executor.py”, line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\executor.py”, line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\executor.py”, line 244, in apply_migration
state = migration.apply(state, schema_editor)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\migration.py”, line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\migrations\operations\models.py”, line 97, in database_forwards
schema_editor.create_model(model)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\base\schema.py”, line 319, in create_model
self.execute(sql, params or None)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\base\schema.py”, line 136, in execute
cursor.execute(sql, params)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\utils.py”, line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\utils.py”, line 64, in execute
return self.cursor.execute(sql, params)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\utils.py”, line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File “G:\django_test_oracle\venv\lib\site-packages\django\utils\six.py”, line 685, in reraise
raise value.with_traceback(tb)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\utils.py”, line 62, in execute
return self.cursor.execute(sql)
File “G:\django_test_oracle\venv\lib\site-packages\django\db\backends\oracle\base.py”, line 497, in execute
return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-00955: name is already used by an existing object
···