Is character set from the user or the database? - oracle

I'm trying to figure out where our project went wrong.
A long time ago, our database administrator created a user and a schema for the project we were working on.
We gave that user to a contractor who created the tables and installed the application.
Today I discovered that our database doesn't support UTF-8 characters and we need it to.
select value from nls_database_parameters
where parameter='NLS_CHARACTERSET'
The result is : WE8ISO8859P1
My question is, was the mistake made when the user was created, or was the mistake done by the contractor who created the tables?
Thanks

The character set is an attribute of the database. So whoever created the database presumably chose the wrong character set. There are no character set related settings when you create a user or create a table (other than determining whether to use the database character set (CHAR/ VARCHAR2) or the national character set (NCHAR/ NVARCHAR2) data types).
Changing the character set of an existing database may take a bit of effort. The Globalization Guide has a section on character set migration. Depending on the Oracle version (the procedure is different in 10g and 11g) and what data already exists, doing an export & import to a new database may be the easiest option.
I should add that the order of operations you specified in your post doesn't make sense. The database has to be created before the user or the schema can be created. So it doesn't make sense that the DBA could have created the user and the schema a long time ago and the contractor created the database more recently. Are you possibly using the terms "database" and "schema" in a non-Oracle context?

Related

Oracle migrate from WE8ISO8859P1 to UTF-8 character encoding for schema table objects only

The current encoding of oracle instance is WE8ISO8859P1 and needs to be moved to UTF-8. I have found some challenges in my database instance due to its current setup and requirements of my business.
This instance in question has 100+ schema users with number of tables created under each schema. We can say logically each schema exists for application or specific system within the enterprise. The requirement is to move only certain schema and their table objects to new character set of UTF-8.
Also, remember the reason for this migration right now is compliance with Restful POST calls that will perform CRUD operations in UTF format.
NLS_NCHAR_CHARACTERSET- AL16UTF16
NLS_CHARACTERSET- WE8ISO8859P1
I did do some research earlier and here are my findings.
• Oracle doesn’t support character encoding at the tablespace , table or column level. Therefore options start reducing for any charset migration strategy at schema level only.
• We have CRUD calls by other enterprise legacy systems to this schema. Therefore should not have a any wider impact. Off course, other schema's in this instance doesn't have any requirements of UTF-8.
The only way I see a solution is
OPTION 1 - Move the target schema and thier objects into new database instance with NLS_LANGUAGE to be UTF-8.
OPTION 2 - Converting all the relevant columns to NCHAR and NVARCHAR but with loss of length and truncation.
Both the approaches lead to big impact and not able to conclude what is best. Any suggestions are welcome that solves my charset migration without impact and changes to other schema in the instance.

Is the Oracle_SID the same the login name on Oracle?

I come from an SQL Server/Sybase background.
I'm used to referring to tables in a particular schema, in the format:
SCHEMA_NAME..TABLE_NAME.
I asked a colleague today about creating a fresh 'schema' on an Oracle database. His response was:
On Oracle you get the Schema name of the logged in user. The schema name is the same as the login user name.
That didn't sound quite right to me. I'm guessing this is an oversimplification, or some concepts are mixed up.
My assumption is the that Oracle_SID is the same as my concept of 'schema' from the Sybase world.
My question is: Is the Oracle_SID the same the login name on Oracle?
Your colleague is right. A schema and a user are pretty much the same in Oracle. When you create a user, a schema with the same name is automatically created.
Quote from the manual:
A schema is a collection of logical structures of data, or schema objects. A schema is owned by a database user and has the same name as that user. Each user owns a single schema
There is no concept of a "database" the way there is in Sybase or SQL Server.
The SID is the identifier for an instance which is something completely different.
A fully qualified table name in Oracle only consists of two elements: the schema (=owner) and the object name: schema_name.table_name and they are separated by a single .
My question is: Is the Oracle_SID the same the login name on Oracle?
The answer to that is: NO, absolutely not
The Oracle System ID (SID) is used to uniquely identify a particular database on a system. For this reason, one cannot have more than one database with the same SID on a computer system.
When using RAC, all instances belonging to the same database must have unique SID's.
A schema is a collection of logical structures of data, or schema objects. A schema is owned by a database user and has the same name as that user. Each user owns a single schema.
refer http://docs.oracle.com/cd/B19306_01/server.102/b14220/schema.htm
you may find the difference between schema vs user
https://dba.stackexchange.com/questions/37012/difference-between-database-vs-user-vs-schema
Oracle SID is beside the point of login name. SID is the identifier of Oracle instance.
Oracle historically considers SCHEMA, ROLE and USER as a very close terms and has common implementation for them. For example, you can create something using command CREATE USER and then drop it using command DROP SCHEMA.

Selection of table (or view) in oracle, that I cannot find in TOAD

I am reverse-engineering an application which administers an Oracle database.
Everything is new to me (application + database)
There is a statement there somewhere, which is:
SELECT * FROM XXX#YYY (XXX is a word, YYY another word)
If I go into my database with TOAD I can't find an 'XXX#YYY' table nor view. If I copy paste the statement in TOAD's editor, I get results as if the table exists.
I know that the '#' symbol is allowed for naming an Oracle object. Is it possible that it means something else here though?
How can I find the table (or view)? Is it possible to get information through a statement such as which schema does 'XXX#YYY' belong to or weather it is a table or a view, so that I can track it?
The database consists of many schemas. There is a default one. Is it possible that XXX#YYY may belong to another schema, rather than the default?
Please help me find the table.
Identifier behind # is database link. It is a way to access objects on some remote Oracle server. more info on http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_5005.htm#SQLRF01205
In Toad/Oracle XXX#YYY means object#database_link.
Look for the schema in your DB, there you will find the table.
Btw: I think its better to use SCHEMA.TABLENAME
If you have problems finding the SCHEMA, go to View->Toad Options, select Treeview at Browser style and then it should display all schemas.

Oracle - ANSI Encoding - KS5601 Character Map

I will be deploying an application database on an existing Oracle Server. I need to store English characters on this database, but my client asked me if this would be a problem, since his Oracle database is using a “KS5601” character map, with “ANSI” encoding. My question is, if I create a new database on an existing Oracle Server instance, would this database have its own encoding, or it will have to follow the current encoding of the server?
If I have to use the KS5601 (Korean Character Map), would I be able to store English alphanumeric characters?
KS5601 is not a database character set. What is the existing database's character set
SELECT *
FROM v$nls_parameters
WHERE parameter LIKE '%CHARACTERSET'
What do you mean when you say "create a new database on an existing Oracle Server Instance"? If you mean that you are creating a new database and a new instance on the same physical server (so you'll have a completely separate SGA & PGA and completely separate set of background processes), you can create the new database with whatever character set you'd like. If you mean that you are creating a new schema in an existing database, you would need to use whatever character set the database uses.

Store cyrillic in Oracle

I have Oracle database with following settings
NLS_CHARACTERSET EE8MSWIN1250
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_LANGUAGE AMERICAN
I've created test table with one column of type NVARCHAR2, where I'm going to store cyrillic.
I use SQL Developer to connect DB.
The problem is when I put a cyrillic chain into DB using SQL Developer cell, the data is stored correctly. But when I use INSERT query with the same data using N'' or not the data is stored as question marks.
Interesting thing is that query generated by SQL Developer, and written by me is identical.
I solved this problem by changing NLS_CHARACTERSET to UTF8, but on production server I can't do such a thing.
IMO it must be some way to store cyrillic into that DB in proper way using query if SQL Developer can do that.
Regards
Depending on the ODBC/JDBC in use, localization settings on your computer may override any config values in the database. Try using ALTER SESSION and set the proper NLS parameters before executing your query, and see if that helps. SQL developer might do this behind the scenes when you edit the data cell.

Resources