Is it possible to use savepoint and rollback in Oracle express edition? - database

I'm using Oracle express edition. Whenever I use the savepoint statement, I get an invalid statement error. Is it not valid in Oracle express edition. I'm using the latest version. I also faced the same problem when I was using the desktops in my university. I don't know what's wrong with it. I'll be so happy with your help. Many thanks.
Edit:
My code:
savepoint s;
The error that I'm getting
ORA-00911: invalid character

ROLLBACK to SAVEPOINT is supported by the free Oracle Database Express Edition.
Tested with the 18c release: https://www.oracle.com/database/technologies/appdev/xe.html
Limitations of this version are listed here: https://docs.oracle.com/en/database/oracle/oracle-database/18/xelic/licensing-information.html#GUID-0F2574A6-360F-4237-8098-17B02FFC3BB3
Your error "00911: invalid character" is related to the way you invoke the "SAVEPOINT S;" command...
For instance in Java, you would need to get rid of the ";" character to make it work:
[...]
Statement s = c.createStatement();
ResultSet r = s.execute( "SAVEPOINT S" ); // "SAVEPOINT S;" will produce ORA-00911
[...]

Just to answer the title question: yes.
SQL> select * From v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for 64-bit Windows: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> savepoint a;
Savepoint created.
SQL> delete from emp;
14 rows deleted.
SQL> rollback to a;
Rollback complete.
SQL>

Related

How do I test whether a given SQL Syntax is valid for an older version of SQL Server

I regularly end up developing on projects where either the Central Test server, or Prod server is an older version of SQL Server than my local install.
e.g. Prod is SQL Server 2014. Local install in SQL Server 2019.
Mostly that's fine, it just means I have to remember to only use old syntaxes. (:cry:)
But occasionally I forget which syntaxes are old. Ooops.
Obviously our test environments catch this, but it would be great to be able to tell my Local Server ... "only accept SS2014 syntax", and have these mistakes caught before they're committed/pushed.
I thought this was what CompatibilityLevel was supposed to do. But either it doesn't, or I'm using it wrong. (See below)
How should I achieve this? (other than just installing a different SQL version!)
Attempt so far:
Run ALTER DATABASE MyLocalProjectDB SET COMPATIBILITY_LEVEL = 120; (120 represents SS2014)
Run SELECT name, compatibility_level FROM sys.databases WHERE name = db_name(); to confirm that the previous command "worked".
Run DROP TABLE IF EXISTS [ATableThatDoesExist], to see if the syntax is accepted. It was.
DROP IF EXISTS was new to SS2016:
MSDN: IF EXISTS ... Applies to: SQL Server ( SQL Server 2016 (13.x) through current version).
Additional Source
Why hasn't this worked?

MSSQL error: "Script level upgrade for database 'master' failed ... upgrade step 'msdb110_upgrade.sql' encountered error 200, state 7, severity 25."

All of a sudden one day (on my DEV PC) my Microsoft SQL Server 2012 instance (installed as instance name "SQL2012") would not start (all my other installed instances did). Trying to start it manually under Services failed. I don't recall making any recent changes prior to this. The cause of the failure was a mystery.
On inspecting Event Viewer, under System it showed a rather amusing error message [emphasis mine]:
The SQL Server (SQL2012) service terminated with the following service-specific error:
WARNING: You have until SQL Server (SQL2012) to logoff. If you have not logged off at this time, your session will be disconnected, and any open files or devices you have open may lose data.
checking under Application Event Log, I found these 2 error messages (preceded by a number of MSSQL$SQL2012 informational messages):
Script level upgrade for database 'master' failed because upgrade step 'msdb110_upgrade.sql' encountered error 200, state 7, severity 25. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.
followed by:
Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.
Fearing having lost my system databases (and not having a backup of them to restore - who makes backups of their system dbs anyway??) and needing to access the instance, and attached databases - I was willing to try anything. Even the possible restore of the system databases: Restoring the SQL Server Master Database Even Without a Backup - but that looked quite complex.
Fortunately, I was eventually able to start the instance (thank you to this answer: https://stackoverflow.com/a/59676743/4993856 which I trusted, because Pinal Dave also mentions that particular switch in: SQL SERVER – Script level upgrade for database ‘master’ failed because upgrade step msdb110_upgrade.sql encountered error 926, state 1, severity 25) if I ran:
net start mssqlserver$SQL2012 /T902
This pointed to some issue with the upgrade script... (Remember SQL is installed with instance name: SQL2012, hence the mssqlserver$SQL2012 used above for the named instance).
After some more searching I discovered this post: Installing service pack / cumulative update on SQL Server 2016 / 2017 breaks database engine (not exactly the same SQL version as mine) which pointed to the following possible Region Settings setting (Control Panel [when viewed by 'icons'] > All Control Panel Items > Region > Administrative > "Change system locale..."):
"Beta: Use Unicode UTF-8 for worldwide language support" in Region Settings
THAT WAS IT!!! After de-selecting that option (and possibly restarting my computer), the MSSQL Server 2012 Instance started up without any issue, and I was able to access all my previously attached databases.
I assume the pending upgrade scripts ran successfully. Thinking back about it now, it is possible that I agreed to installing a SQL Update, and never bothered to test access to the instance afterwards.
I also don't recall exactly why I chose to enable that specific setting under Region Settings, possibly due to some Linux compatibility, but it looks like it has become defaulted 'on' in recent Windows builds.
I got the same problem SQL2017 after update Windows Patch Hotfix3391(KB5001228)
after restart server MSSQL Fail to start and event viewer shown error below
Script level upgrade for database 'master' failed because upgrade step 'msdb110_upgrade.sql' encountered error 200, state 7, severity 25. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.
Solution
Fix by remove Beta:Use Unicode UTF-8 for Worldwide lang.. in the Region Settings
Then it require restart server. After restart MSSQL can start as normal.
The problem is the msdb_110.sql update script, the script is a bit of a mess, with mixed tabs and spaces (wtf?).
It tries to run a couple of procedures that fail, on startup of sql-server. They fail when the code-page is 65001 (usually because the BETA utf-8 code page option has been selected) and so SQL server fails to start.
This appears to happen any time a SQL Server update is installed. I only experience this error with SQL Server 2017, not 2019
Why?
Don't know? The script is a mess.
Solution
Deselect the use utd-8 code page option
Restart the machine
Start sql server and let it run the script
(optional) reselect the use utd-8 code page option
Restart machine again and sql server
(optinal but recommended) uninstall windows, install a unix and run postgres

EXP-0003 No storage definition found for segment (0,0) error while using EXP for export

I am trying to export a schema using EXP command on the server which is throwing me error EXP-0003 No storage definition found for segment (0,0).
exp userid=user/pass#SID file=vmper01cm_30Sep2015.dmp log=vmper01cm_30Sep2015.log statistics=NONE
The export release it shows me is -- Export Release 11.2.0.1.0 - Production on Wed Sep 30 02:38::31 2015
and Database is
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
I am not sure if it is because of the varying version of export release and database release or there is another cause for it.
The error are also showing for tables where are no rows (empty tables).
I have later perform an export on our 10g machine where the export release and database release are same and it says export terminated with no warnings.
This is for 10g database
Export: Release 10.2.0.4.0 - Production on Mon Sep 28 12:01:09 2015
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
You should use exp version 11.2.0.4.0(the same as the server has), although in this case it more looks like a bug in Oracle's exp utility.
AFAIK you have problem with "SEGMENT CREATION DEFERRED" table parameter.
These tables allocate the space on demand, when the 1st row is inserted in to them. This is 11g feature.
You can call:
alter table <table name> allocate extent;
as workaround.

how to open a database in sqlplus which is already created

In SQL*plus i can't open the databse which is already created in my computer....
the error it shows that "the database is not yet open"
and i want to know that in what command is suitable to open database.
I assume you're getting an error such as ORA-01219: database not open: queries allowed on fixed tables/views only. In that case, the fix is to connect as SYS and execute ALTER DATABASE OPEN:
C:\Users\Luke>sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Sun Mar 17 10:31:40 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
SQL> select count(*) from user_tables;
select count(*) from user_tables
*
ERROR at line 1:
ORA-01219: database not open: queries allowed on fixed tables/views only
SQL> alter database open;
Database altered.
SQL> select count(*) from user_tables;
COUNT(*)
----------
935
If you get an error ORA-01507: database not mounted when you run ALTER DATABASE OPEN, run ALTER DATABASE MOUNT before ALTER DATABASE OPEN.
There might a reason why the database isn't open and/or mounted. Perhaps it failed to open? In that case, ALTER DATABASE OPEN is likely to result in an error other than ORA-01507. If so, the folks on https://dba.stackexchange.com/ should be able to help you.

Statement failed, SQLSTATE = -922 my_database.gdb is not a valid database

I just can't connect to Firebird on Ubuntu.
Through the terminal I do:
rafaeljesus#ubuntu:/tmp$ isql-fb
Use CONNECT or CREATE DATABASE to specify a database
SQL> connect .my_database.gdb user sysdba password masterkey;
Statement failed, SQLSTATE = -922
file /tmp/cnes.gdb is not a valid database
Searching on the web I realized that this occurs when the file is corrupted, which is not the case ... I do not know if this is because the file is in gdb. instead of fdb..I do not know about Firebird ...
I really need some help.
As you don't specify any version information, ODS version of the database, if you upgraded the Firebird version, or whether this database was moved from another system etc I provide some options:
The database was created on a 32 bit platform and now moved to a 64 bit platform without backup/restore: older file structures of Firebird (at least ODS 10 from Firebird 1.0 and InterBase 6) are specific to the bitness of the platform: a backup on the 32 bit platform and a restore on the 64 bit platform should suffice
The database was created on a big-endian platform and now moved to a little-endian platform without backup/restore
NOTE: In both cases make sure you create a transportable backup (it is the default, but check).
Another option could be that a restore of the database failed before the full database was restored. Check your restore log and address any errors (see Firebird 2.5 reports "is not a valid database" although it is for a suggestion )
If all else fail: contact a Firebird/Interbase recovery/repair company like IB Surgeon.

Resources