Import table in Oracle Sql Developer - sql

I am using Oracle Sql Developer. I have a table in one schema. I want to copy this table into another schema with its all data. How can I do this?
Thanks,

CREATE TABLE schema1.new_table
AS (SELECT * FROM schema2.old_table);
You need to make sure you grant proper access to the schemas. Here is a Tutorial

Related

How to create database table when using Wildfly?

I am trying to complete a tutorial on a simple javaEE project using wildfly. The first step is creating two tables in my database. As it says I should create my tables like this: "CREATE TABLE wildfly.name...." but it gives me an error saying thet wildfly is unknown.
Link to the tutorial: click here
My question is why should i put "wildfly." before the table name and how can I solve this error?
Thank you for your help!
Note: I am using oracle database instead of mysql
It's a misleading MySQL tutorial example because in Oracle syntax "wildfly." is a user(schema) in the Oracle database.
Schema/user in Oracle is a namespace for tables and other objects. So, when you issue such a statement - you're telling oracle to create table in namespace WILDFLY. If you don't have such user in your database or you don't have rights to access such user/schema - you can't create tables there.
You should create such user in Oracle database (or alter your statement to another user/schema name that you actually have in your database) and put your tables there.
For example these statements are correct because I created WILDFLY user before putting tables to it:
CONNECT SYS/****#ORCL AS SYSDBA
CREATE USER WILDFLY IDENTIFIED BY WILDFLYPASSWORD;
GRANT UNLIMITED TABLESPACE TO WILDFLY;
CREATE TABLE WILDFLY.MYTABLE...

is it possible to update tables using synonyms

I have synonyms in my database which is refering one table in different DB. Is it possible to update the table using synonymn name?
Yes, you can update by using below method( for oracle db ):
create public database link db2 connect to myschema using 'abc-scan.mycompany.com.tr:1521/db2.mycompany.com.tr';
create synonym syn_table1 for table1#db2;
update syn_table1 set col1=value1

Can we create database in SAP HANA?

I am new to SAP HANA and I created a new user in SAP HANA hdbsql(command line) by
hdbsql=>create user username password password
Now I am trying to create a database with the query,
hdbsql=>CREATE DATABASE dbname
But I could not create the database?Could anyone provide a solution for this.Thank you.
The SAP HANA database does not have the concept of different databases, but of schemas instead. So if you want to create a "container" for your tables, you have to create your own schema. The definition of the CREATE SCHEMA statement can be found here:
https://help.sap.com/saphelp_hanaplatform/helpdata/en/20/d4ecad7519101497d192700ce5f3df/content.htm
This is also a good reference for the SQL syntax of HANA. The most easiest query to create a schema would look like this:
CREATE SCHEMA schemaname
I found two document which shows HANA can create database.
https://developers.sap.com/tutorials/hxe-ua-dbfundamentals-tenantdb.html
https://help.sap.com/viewer/4fe29514fd584807ac9f2a04f6754767/2.0.04/en-US/65cd51970fa44f36a4c9083915cf3162.html

Adding a column to a SQL database in AZURE

I am new to the AZURE environment.
I have a SQL Database on AZURE and I need to add 2 columns to a table. While I am in the Portal I do not recognize anything that will allow me to alter the design of a table. I am using SSMS 2012 but when I look at the database on the azure server I do not have the design option.
Any help would be greatly appreciated.
From SSMS:
Connect to the databse
Execute your ALTER TABLE statements to create the columns.
From the portal:
SQL Databases
Select the one you're working with
Click Manage
Log in
New Query
Execute your ALTER TABLE statements to create the columns.
The designer in SSMS is buggy and most people I talk to advise against using it.

SELECT data from another schema in oracle

I want to execute a query that selects data from a different schema than the one specified in the DB connection (same Oracle server, same database, different schema)
I have an python app talking to an Oracle server. It opens a connection to database (server/schema) A, and executes select queries to tables inside that database.
I've tried the following :
select ....
from pct.pi_int, pct.pi_ma, pct.pi_es
where ...
But I get:
ORA-00942: table or view does not exist
I've also tried surrounding the schema name with brackets:
from [PCT].pi_int, [PCT].pi_ma, [PCAT].pi_es
I get:
ORA-00903: invalid table name
The queries are executed using the cx_Oracle python module from inside a Django app.
Can this be done or should I make a new db connection?
Does the user that you are using to connect to the database (user A in this example) have SELECT access on the objects in the PCT schema? Assuming that A does not have this access, you would get the "table or view does not exist" error.
Most likely, you need your DBA to grant user A access to whatever tables in the PCT schema that you need. Something like
GRANT SELECT ON pct.pi_int
TO a;
Once that is done, you should be able to refer to the objects in the PCT schema using the syntax pct.pi_int as you demonstrated initially in your question. The bracket syntax approach will not work.
In addition to grants, you can try creating synonyms. It will avoid the need for specifying the table owner schema every time.
From the connecting schema:
CREATE SYNONYM pi_int FOR pct.pi_int;
Then you can query pi_int as:
SELECT * FROM pi_int;
Depending on the schema/account you are using to connect to the database, I would suspect you are missing a grant to the account you are using to connect to the database.
Connect as PCT account in the database, then grant the account you are using select access for the table.
grant select on pi_int to Account_used_to_connect