Creating Multiple table in Oracle - oracle10g

I am using Oracle Express 10g and I'm enter the following text to create 2 tables in the sql command line, but it is not working.
CREATE TABLE student (
matric_no VARCHAR2(8),
first_name VARCHAR2(20),
last_name VARCHAR2(20),
date_of_birth DATE
);
CREATE TABLE student1 (
matric_no VARCHAR2(8),
first_name VARCHAR2(20),
last_name VARCHAR2(20),
date_of_birth DATE
);
Can anyone see what I am doing wrong.
Thanks

By "command line" you probably mean the web application that comes with Oracle Express 10g. This application has several browser incompatibilities and is basically unable to execute several statements at once (also see Oracle 10g - invalid character on DB importing).
Either put your statements in a text file and upload them as a SQL script. Or switch to a better tool such as SQL Developer (downloadble from Oracle web site).

Are you sure you didn't type this out in WORD?
Sometimes there are problems with "invisible" characters. For example if you hit TAB in WORD, it will store it as a special character which will thereby cause an error when you try running it in SQLPlus.

Related

Golang and Postgresql CREATE TABLE giving me problems

Using and following the documentation:
https://godoc.org/github.com/lib/pq
but can't see after hours and hours and research online to find any good example of passing variables to the db.Exec()
I'm building a program that will create new tables depending on certain names entered on the command arguments.
db.Exec(`CREATE TABLE $1(
ID INT PRIMARY KEY NOT NULL,
HOST TEXT NOT NULL,
PORTS TEXT,
BANNERS TEXT,
JAVASCRIPT TEXT,
HEADERS TEXT,
COMMENTS TEXT,
ROBOTS TEXT,
EMAILS TEXT,
CMS TEXT,
URLS TEXT,
BUSTIN TEXT,
VULN TEXT
)`, tablename)
But no luck, I obviously have try to change things around, even I have try
to build the CREATE TABLE syntax on a string and have try to pass that instead of db.Exec(string)
but no luck neither...
can someone give me a hand?
Thanks
You can check on https://golang.org/src/database/sql/sql.go?s=39599:39668#L1437, at line 1478, that sql statements will be first prepared then executed.
In PostgreSQL, prepare are only valid for SELECT, INSERT, UPDATE, DELETE, or VALUES, https://www.postgresql.org/docs/10/static/sql-prepare.html .
Here you can use Go's fmt.Sprintf to support creating different tables, and check table name manually, SQL table names can contain many special characters, but you can narrow it, mine validation is regexp.MustCompile("^[a-zA-Z_]+[0-9a-zA-Z_]*$") .

ORA-12899 - value too large for column when upgrading to Oracle 12C

My project is going through a tech upgrade so we are upgrading Oracle DB from 11g to 12c. SAP DataServices is upgraded to version 14.2.7.1156.
The tables in Oracle 12C is defaulted to varchar (byte) when it shoud be varchar (char). I understand this is normal. So, I altered the session for each datastore running
`ALTER session SET nls_length_semantics=CHAR;`
When I create a new table, with varchar (1), I am able to load unicode characters like Chinese characters (i.e 东) into the new table from Oracle.
However, when I try to load the same unicode character via SAPDS into the same table, it throws me an error 'ORA-12899 - value too large for column'. My datastore settings are:
Locale
Language: default
Code Page: utf-8
Server code page: utf-8
Additional session parameters:
ALTER session SET nls_length_semantics=CHAR
I would really appreciate to know what settings I need to change in my SAP BODS since my Oracle seems to be working fine.
I think, you should consider modifying table column from varchar2(x BYTE) to varchar2(x CHAR) to allow Unicode (UTF-8 format) data and avoid ORA-12899 .
create table test1 (name varchar2(100));
insert into test1 values ('east');
insert into test1 values ('东');
alter table test1 modify name varchar2(100 char);
-- You can check 'char_used' for each column like -
select column_name, data_type, char_used from user_tab_columns where table_name='TEST1';

postgresql - losing command prompt after select from quoted table name

At a relational database command prompt, normally if you enter a query, then you get data back, followed by a new command prompt. Postgresql does this for me too when I select from a table with no quotes in the name. I'm trying to debug the Postgresql setup for a sample Scala application that uses quoted table names, though, and when I select from one of these manually with psql, I get the data, but it is followed by text on an inverted-color background that says
(END)
instead of a new command prompt, and I can't seem to get the command prompt back. What's going on? I haven't found mention of this behavior of Postgresql anywhere.
I'm using a new install of Postgresql 9.3 on Ubuntu 14.04. Attempting to follow instructions in the book the above-linked sample application came from, I'm executing
CREATE TABLE "user" (
id bigserial PRIMARY KEY,
email varchar NOT NULL,
password varchar NOT NULL,
firstname varchar NOT NULL,
lastname varchar NOT NULL
);
Then I'm executing something in the sample application that through a lot of indirection ends up inserting a single row to this table. I don't think the details of this should be relevant. Then as a test I am manually executing the following in psql:
select * from "user";
This ought to be about as trivial as you can get. I'm an old hand at Oracle, but completely new to Postgresql. I see that using quoted names is considered bad practice by many, but I'm trying not to perturb the sample application any more than I have to.
How do I get my command prompt back?
After a query is returned and the results are being displayed, psql switches to a vi/less-like view of the results. Try hitting q to exit that view again and your command prompt should return.
We can return back to original terminal by giving Ctrl+C. This works for me in Psql Version 12.

Is there a free web based tool to view the database schema and its properties

Is there a free web based tool (I prefer Microsoft because I have an MSDN account) to view the database schema and its properties? I'm currently using Visio but I dont know if it's possible in Visio to do the following:
View the database schema that I will upload in a Sharepoint workspace.
If I click the name of the Database table, it will either pop up a small window with its database properties and column description or another window will pop up with its database properties and column description.
For example I have a Schema table interface composed of a profile and time tables.
THESE ARE JUST EXAMPLES.
ProfileDim table
Profile ID number(10)
FirstName varchar (20)
MiddleName varchar (20)
LastName varchar (20) TimeDim Table
DateHired datetime---------------EmployeeStartDate datetime,
Date_Name nvarchar(50),
Year datetime,
If I click the name "TimeDim" it will take me to another page where I can see the database properties written below and the description of each column. I prefer not to use MS excel or word. I want a tool that I could edit, delete in case I want to add another column, change the data type and change the name etc.
TimeDim table
COLUMN NAME DATA TYPE ALLOW NULLS DESCRIPTION
EmployeeStartDate datetime, Unchecked "START DATE OF THE EMPLOYEE"
Date_Name nvarchar(50), Checked "CURRENT DATE NAME"
Year datetime, Checked "NAME OF THE CURRENT YEAR"
There are several tools that generate your database documentation to for example html. I don't know online tools but the generated docs can be placed online ofcourse. They are not free but you can use them in the evaluation perio to generate the database documentation
toad data modeler
dbdesc
dezign for databases
For Microsoft DB servers, you can use SQL Server Management Studio Express.
The DB schema management tool depends on which database software you are using. There are different tools to MySQL, PostgreSQL, Microsoft SQL Server, etc...

Table invisible in PostgreSQL - Undefined relation issue at different sessions

I have executed the following create statement using SQLWorkbench at my target postgresql database:
CREATE TABLE Config (
id serial PRIMARY KEY,
pub_ip_range_low varchar(100),
pub_ip_range_high varchar(100)
);
Right after table creation I request the table content by typing 'select * from config;' and see that table could be retrieved. Nevertheless, my java program that uses JDBC type 4 driver cannot access the table when I issue the same select statement in it. An exception is thrown when the program tries to access it which says says "Undefined relation" for the config table.
My questions are:
Why sqlworkbench where I had previously run the create statement recognizes the table while my java program cannot find it?
Where does the postgressql DBMS puts the tables I created? I don't see them neither in public nor in information schema.
NOTE:
I checked target postgres database and cannot see the table Config anywhere although SQL workbench can query it. Then I opened another SQL workbench instance and noticed that the table cannot be queried (i.e. not found). So, my conclusion is that PostgreSQL puts the table I created in the first running SQLBench instance into some location that is bound to that session. Another SQL Workbench instance or my java program is not bound to session, so cannot query the previously created table config.
The only "bloody location" that is session-local in PostgreSQL is the schema pg_temp, in other words: temporary tables. But your CREATE command does not display the keyword TEMP[ORARY]. Of course, as long as the transaction is not commited, nobody sees anything outside the transaction.
It's more likely you are seeing a switcheroo of hosts / databases / ports / or the schema search_path. A mixup with the mixed-case table name is a hot candidate, too. If you don't double-quote "Config", the table ends up all lower case in the system, so: config. If you later double quote the name, it won't match. The manual has the details.
Maybe the create failed on the extra trailing comma?
CREATE TABLE config (
id serial PRIMARY KEY,
pub_ip_range_low varchar(100),
pub_ip_range_high varchar(100) -- >> ,
);