Namespace error while importing to oracle 12c - sql

I'm a newbie in Oracle 12c who is trying to follow this tutorial.
I've create a new connection orcl/SYSTEM/oracle and logged in as SYSTEM/oracle in SQL developer command line.
The problems is that when I'm trying to import twitter_data.imp from that demo.zip file:
imp dmuser/dmuser file=twitter_data.dmp log=twitter_data.log full=y
It says there's no "TBS_1" namespace. How can I globally create this namespace for oracle 12c (in my new connection). I'm kinda thinking about it should be namespace for table (but there's none, right?).
Thanks.

It's possible you're missing a TABLESPACE; try the following
CREATE TABLESPACE TBS_1 DATAFILE 'TBS_1_dat' SIZE 500K AUTOEXTEND ON NEXT 300K MAXSIZE 100M;

If you have a Oracle SQL Developer, then go to the database connection you have created and click on Manage Database. You would be provided with the list of all tablespace along with the capacity and free space.
twitter_data.dmp file might have been created on the tablespace "TBS_01". While restoring it will search for the same.
Create the tablespace as below while connecting as SYSDBA -
CREATE TABLESPACE tbs_perm_02 DATAFILE 'tbs_01.dat' SIZE 500M
The path of the dat file to be created is up to you, plus auto-extend and other options you choose freely.

Related

is there a way to restore oracle database from file system backup

i have oracle DB 11g for tester and one junior DBA removed one of system tablespace files from OS by mistake and DB in no archive mode and i tried to recreate file in mount mode and recover database but couldn't as there are no archivelogs .
if i have filesystem backup for datafiles and control files can i restore the database from it . or just use the old control file to restore database to earlier point before creation of that dropped system datafile ?
i tried to take it offline first and then tried to recreate it but for first step it tells me that file is offline and database can't start and for second method it ask me to recover datafile which i can't because of no archive mode
.
1- alter database datafile '/data/oradata/umiasdb/users55.dbf' offline drop;
ORA-01147: SYSTEM tablespace file 139 is offline
ORA-01110: data file 139: '/data/oradata/umiasdb/users55.dbf'
2- ALTER DATABASE CREATE DATAFILE '/data/oradata/umiasdb/users55.dbf' AS '/data/oradata/umiasdb/users55.dbf';
ORA-01113: file 139 needs media recovery
ORA-01110: data file 139: '/data/oradata/umiasdb/users55.dbf'
You can't easily open the database in this case. To force-open the database, you need: _ALLOW_RESETLOGS_CORRUPTION and bbed (block edit tool) to edit your datafile header in hex.
You can also try unload data by data unload software as can be seen here.

How to rename database using phpMyAdmin tool?

I created a fresh database in phpmyadmin which does not contain any tables yet since its fresh, however I accidentally made a typo. How can I rename the database?
If this happens to me I usually just execute the SQL command:
DROP DATABASE dbname;
and create another database. But is it possible to rename it? I was already searching SO but found nothing helpful.
I found two possible solutions.
Rename it via the phpmyadmin backend UI (preferable):
Or just execute this SQL (only use it if the database is fresh and does not contain any data yet, otherwise it will be lost!)
CREATE DATABASE newname;
DROP DATABASE oldname;
ALTER DATABASE oldName MODIFY NAME = newName
I don't think you can do this. I think you'll need to dump that database, create the newly named one and then import the dump.
If this is a live system you'll need to take it down. If you cannot, then you will need to setup replication from this database to the new one.
If you want to see the commands try this link, Rename MySQL database
Try using an aux temporary db (as copy of the original)
$ mysqldump dbname > dbname_dump.sql //create a backup
$ mysqladmin create dbname_new //create your new db with desired name
$ mysql dbname_new < dbname_dump.sql //restore the backup to the new one
$ mysql drop database dbname; //drop old one

How to attach database in SQL Server 2008 R2 without index.idx file

I have a database test (test.mdf, test_ldf.log and test_idx.idx). By mistake I deleted the test_idx.idx file and due to file was over 20 GB.
I have used all type of recovery software but can't find the file.
Unfortunately that database is not backed up, and now SQL Server 2008 R2 doesn't let me attach the database.
Is there any way to attach the database test.mdf file without index file?
Error when I try to attach database:
Unable to open the physical file ".idx". Operating system error 2: "2(failed to retrieve text for this error. Reason: 15105)". (Microsoft SQL Server, Error: 5120)
create a dummy database (name is not important) with the same file structures. ie a data file, log file and index file.
take the index file and database offline like so:
alter database <dbname> modify file(name = '<name of your index file>', offline)
alter database <dbname> set offline
You'll not be able to recover the offline file (to my knowledge) so dont give it the same logical name as your original file - you'll see why in a moment.
now overwrite the dummy database files with what you have left of your broken database (obviously keep the copies somewhere safe!)
bring the database back online
alter database <dbname> set online
At this point your data should be accessible.
create new filegroup/file with the same logical names as your original and rebuild indexes
Good Luck!

Unexpected output from using "create database"

My current task is to create a .bat file that can manually create an Oracle database, so that a Database Configuration Assistant is no longer necessary.
I am following this guide.
I am stuck at "Creating the database". Upon typing:
SQL> create database ORA10
I do not get the expected output as described on the guide:
SQL>create database ora10
logfile group 1 ('D:\oracle\databases\ora10\redo1.log') size 10M,
group 2 ('D:\oracle\databases\ora10\redo2.log') size 10M,
group 3 ('D:\oracle\databases\ora10\redo3.log') size 10M
character set WE8ISO8859P1
national character set utf8
datafile 'D:\oracle\databases\ora10\system.dbf'
size 50M
autoextend on
next 10M maxsize unlimited
extent management local
sysaux datafile 'D:\oracle\databases\ora10\sysaux.dbf'
size 10M
autoextend on
next 10M
maxsize unlimited
undo tablespace undo
datafile 'D:\oracle\databases\ora10\undo.dbf'
size 10M
default temporary tablespace temp
tempfile 'D:\oracle\databases\ora10\temp.dbf'
size 10M;
Instead I get a bunch of numbered input requests:
SQL> create database ORA10
2 and
3 it
4 doesn't
5 seem
6 to
7 stop
8 asking
9 for
10 inputs
Other sources/guides I've googled look similar to the aforementioned guide. As far as I know (I might not be using the right keywords), my output is not supposed to happen. I am unable to identify what is going on here.
Please note that I don't actually know much about SQL or using command prompt. My background is limited to classroom HTML/CSS/Java/Python. I have been dared to complete a number of programming related tasks within a certain period of time (a week) without any instruction or preparation - though I am allowed to use the internet for assistance. So far so good until now.
Any assistance will be appreciated, thank you in advance.
All the lines in your listing from create database ORA10 to size 10M; including the last semicolon are not output, but instead part of one single statement. The semicolon terminates it and tells the command interpreter to execute what you've written. Therefore it is continuing to ask you for input until you tell it you're done (with the semicolon).
If you simply want to create a database without specifying any other options, you can simply add a semicolon. The following will create a database with the name "ORA10" in the default configuration:
CREATE DATABASE ORA10;

Create database explicitly before restoring to it?

When I setup my PostgreSQL server one of the first things I will do is import a database for an external source. Which of the following is the right way to do it?
Create a database called "NEWDB" on the PostgreSQL server and then
import my external "BACKUPDB" database from my pg_dump into the
"NEWDB".
Don't create a database on the PostgreSQL server, and import the
"NEWDB" database, thereby automatically creating "NEWDB" on the
postgresql server.
I guess my question is, if I want to import an existing database to the PostgreSQL server, do I first need to create a database for it to go into?
You don't have to. It depends on what you want to achieve. If you dump a single database with pg_dump, CREATE DATABASE and ALTER DATABASE commands are not included. You are expected to connect to an existing database. So you have to create it first.
I quote advice from the manual:
If your database cluster has any local additions to the template1
database, be careful to restore the output of pg_dump into a truly
empty database; otherwise you are likely to get errors due to
duplicate definitions of the added objects. To make an empty database
without any local additions, copy from template0 not template1, for
example:
CREATE DATABASE foo WITH TEMPLATE template0;
And also:
The dump file also does not contain any ALTER DATABASE ... SET
commands; these settings are dumped by pg_dumpall, along with database
users and other installation-wide settings.
pg_dumpall, on the other hand, dumps the whole DB cluster including meta-objects like users. It includes CREATE DATABASE statements and connects to each DB when restoring. You can even include DROP DATABASE statements with the -c (--clean) option. Careful with that.
Every instance of PostgreSQL has a default maintenance db named "postgres" that you can connect to - to create databases for instance or start a full restore (from pg_dumpall). But a single-DB dump (from pg_dump) has to be run against its target database.
Finally:
Once restored, it is wise to run ANALYZE on each database so the
optimizer has useful statistics. You can also run vacuumdb -a -z to
analyze all databases.