Create a new table from another table that exists ussing a stored procedure

Hi,
I want to know if is posibble to create a new table from another table that exists ussing a stored procedure. This new table is created from other table that exists in the DB.
(in the next code the table tbl1 exist into the schema of the DB, but temp_tbl1 does not exist, it must be created by the procedure)
create or replace procedute temp is
temp_tbl1 tbl1%TYPE; //the temp_tbl1 will have the same type of tbl1
begin
create table temp_tbl1 as (select * from tbl1);
end temp;
thanks very much

cat wrote:
Hello,
I think my problem is not about this grant, because if I execute this as an "anonymous procedure":
DECLARE
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE Abonus (id NUMBER, amt NUMBER)';
END;
It runs ok
But if I do:
CREATE OR REPLACE procedure temp as
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE Abonus (id NUMBER, amt NUMBER)';
END;
I have the error
ORA-01031: Insufficient privileges
ORA-06512: at "temp", line 3Anonymous blocks are treated as "Invoker's Rights" from a privilege perspective whereas stored programs by default are treated as "Definer's Rights". Therefore using anonymous blocks is not a valid test to check this.
The simplest form of checking this issue is by executing
SET ROLE NONE;and then to run your statement/code block in question interactively. Using this approach you get in your session the effective rights of a "Definer's Rights" stored program, i.e. only privileges that you got granted directly to your user.
You can revert to the default setting by issuing
SET ROLE ALL;For more information regarding this topic, read e.g. the documentation:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/subprograms.htm#LNPLS00809
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/

Similar Messages

  • Is it possible to create a new List from another List's template and NOT carry over the associated Workflow?

    Related to
    this post, in cases where it's desirable to have two different workflows for two different Lists—is it possible to NOT bring forward a hardwired workflow when creating a new List from a saved template?
    I.e. List #2 still has the workflow from List #1 hardwired in.  List #1 still needs its workflow but List #2 wants to have a separate Workflow.

    More importantly, because it's relatively easy for most folks to just start from scratch with a new Workflow—how does one disassociate a carried-over Workflow from the new List?
    Use the web-GUI. (List Settings > Workflow Settings)
    From Designer, there's a shortcut button at the top of the page in the Workflows tab: "Administration Web Page".

  • Can I create a new table using strcuture of another existing table ????

    hello all -
    If I need to create table as the duplicate table for another table. I donot need data from that table, as I am going to populate date later on.
    So all need is the structure, constraints of the table to create a new table.
    create table new_temp as
    select * from old_temp;
    above command creates a table with the data, what if I donot want the data, only the defination.
    Any help woud really appreciated.
    Thanks
    Rama

    but create table as select..
    CAN'T create constraint on new table it copy only data
    not constraint
    so create new table with structure as well as
    constraint use
    SELECT dbms_metadata.get_ddl('TABLE','EMP') FROM DUAL;
    only in 9i
    kuljeet pal singh

  • How can I create a new table from a filed cell?

    Every time that I fill a row of cells I want to creat a new table with the content of that cells.
    How can I do it?
    Donw here it´s the example.
    From the top table, I want to fill these rows, and everytime that it´s done, I want that a new table apears like the cells under.
    There is any Way to do it?
    In the Spanish version of Number I found in the references formulas, one formula called "DIRECTION" that describes to do this.
    But I found no way to do it.
    The above formula it´s this:
    =DIRECCION(row; collumn; type of direction; stile of direction; table name)
    Anyone can help me?
    I really need this solution.

    Otto,
    Based on the syntax you quoted for that function, the english equivalent is "Address". It doesn't create a Table, but rather it creates an Address that references a Cell, in the form of a String. The common, and only, use that I am aware of for Address is to use it as the parameter for INDIRECT. For example: INDIRECT(ADDRESS)) will produce a reference to a table cell, but it will not produce a table.
    Jerry

  • Can you create a new table from an Excel spreadsheet

    It would be GREAT if there was a way to use SQL Developer to take an Excel Spreadsheet, and create a new table based on it - does anyone know if that's possible?
    Thanks,
    Brad Blake

    Excellent - yes, from the thread on the SQLDeveloper website, it looks like you will be able to create a new table from an .xls file - very cool!
    Does anyone know when version 1.1 is supposed to be coming out?
    --Brad                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • I'm unable to create a new Table on SQL Azure.

    I'm trying to create a new table in my custom database. But i'm getting this error message:
    'Filegroup reference and partitioning scheme' is not supported in this version of SQL Server.'
    Here is the sample create schema:
    CREATE TABLE dbo.[Contact](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [FirstName] [nvarchar](250) NULL,
    [LastName] [nvarchar](250) NULL,
    [InsertDateTime] [datetime] NULL,
    [UpdateDateTime] [datetime] NULL,
    [PhoneNo1] [nvarchar](50) NULL,
    [CellNo1] [nvarchar](50) NULL,
    [IsActive] [bit] NOT NULL,
    CONSTRAINT [PK_Contact] PRIMARY KEY CLUSTERED
    [ID] ASC
    )WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    BT

    In addition to Neil's comment, I would add that one of the major strengths of SQL Azure is its simplicity from an administrative standpoint while providing as much parity as possible for the relational and programming stack.  In somes
    cases, less is more. SQL Azure is an example.  By having a simpler system we are able to get certain capabilities not available on premise. Take a look at the CREATE DATABASE XYZ AS COPY OF operation for example, you do not have to worry about finding
    a server with enough space; you do not have to worry about moving files around a network or creating shares between machines; and best of all, you do not have to any kind or provisioning of cleanup as a result of cloning a database. The upcoming Data Federation
    feature is another example of what you can achieve when you are free of underlying configuration details.
    That's not to say SQL Azure wouldn't benefit from some capabilties of the SQL Server platform (for example TDE); but personally I am happy that two years later we still don't have to worry about many of those low-level configuration details.
    Herve Roggero, Blue Syntax MVP SQL Azure Co-Author: Pro SQL Azure

  • Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.

    Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.
    when you copy n paste into a new table, all the cell sizes are changed.
    is there a way to put in a new table from your templates into an existing file, different to the standard very basic ones in insert table.
    I look forward to your answers.  Your help is very much appreciated.
    Also how do you search for question answers already written in this support area please.

    Hi Jason,
    In Numbers 3, you can select a whole table by clicking once in the table to make it active, then click once on the "bull's eye" at the top left.
    Now copy and paste. All formatting (and any cell content) is pasted intact. In Numbers 2.3 (Numbers '09) it is a little different for selecting a whole table. But I won't go into that unless you are using Numbers '09. Please reply.
    I don't like the look of the tables in Insert Table. I keep custom tables in My Templates. I have set Numbers > Preferences > General > For New Documents > Use template: (name of my favourite custom template)
    That opens when I launch Numbers, or ask for a new document (command n). Note that if you follow this preference setting, then Menu > File > New From Template Chooser (for another template) requires you to hold down the option key in that menu.
    Regards,
    Ian.
    Message was edited by: Yellowbox. All formatting (and any cell content) is pasted intact.

  • How can I create a new table in a MySQL database in MVC 5

    I have an MVC 5 app, which uses MySQL hosted in Azure as a data source. The point is that inside the database, I want to create a new table called "request". I have already activated migrations for my database in code. I also have the following
    code in my app.
    Request.cs: (inside Models folder)
    public class Request
    public int RequestID { get; set; }
    [Required]
    [Display(Name = "Request type")]
    public string RequestType { get; set; }
    Test.cshtml:
    @model Workfly.Models.Request
    ViewBag.Title = "Test";
    <h2>@ViewBag.Title.</h2>
    <h3>@ViewBag.Message</h3>
    @using (Html.BeginForm("SaveAndShare", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
    @Html.AntiForgeryToken()
    <h4>Create a new request.</h4>
    <hr />
    @Html.ValidationSummary("", new { @class = "text-danger" })
    <div class="form-group">
    @Html.LabelFor(m => m.RequestType, new { @class = "col-md-2 control-label" })
    <div class="col-md-10">
    @Html.TextBoxFor(m => m.RequestType, new { @class = "form-control", @id = "keywords-manual" })
    </div>
    </div>
    <div class="form-group">
    <div class="col-md-offset-2 col-md-10">
    <input type="submit" class="btn btn-default" value="Submit!" />
    </div>
    </div>
    @section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    HomeController.cs:
    [HttpPost]
    public ActionResult SaveAndShare(Request request)
    if (ModelState.IsValid)
    var req = new Request { RequestType = request.RequestType };
    return RedirectToAction("Share");
    The point is that, I want the user to fill the form inside the Test view and click submit, and when the submit is clicked, I want a new entry in the new table to be created. But first of course I need to create the table. Should I create it using SQL query
    through MySQL workbench? If yes, then how can I connect the new table with my code? I guess I need some DB context but don't know how to do it. If someone can post some code example, I would be glad.
    UPDATE:
    I created a new class inside the Models folder and named it RequestContext.cs, and its contents can be found below:
    public class RequestContext : DbContext
    public DbSet<Request> Requests { get; set; }
    Then, I did "Add-Migration Request", and "Update-Database" commands, but still nothing. Please also note that I have a MySqlInitializer class, which looks something like this:
    public class MySqlInitializer : IDatabaseInitializer<ApplicationDbContext>
    public void InitializeDatabase(ApplicationDbContext context)
    if (!context.Database.Exists())
    // if database did not exist before - create it
    context.Database.Create();
    else
    // query to check if MigrationHistory table is present in the database
    var migrationHistoryTableExists = ((IObjectContextAdapter)context).ObjectContext.ExecuteStoreQuery<int>(
    string.Format(
    "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__MigrationHistory'",
    // if MigrationHistory table is not there (which is the case first time we run) - create it
    if (migrationHistoryTableExists.FirstOrDefault() == 0)
    context.Database.Delete();
    context.Database.Create();

    Hello Toni,
    Thanks for posting here.
    Please refer the below mentioned links:
    http://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/
    http://social.msdn.microsoft.com/Forums/en-US/3a3584c4-f45f-4b00-b676-8d2e0f476026/tutorial-problem-deploy-a-secure-aspnet-mvc-5-app-with-membership-oauth-and-sql-database-to-a?forum=windowsazurewebsitespreview
    I hope that helps.
    Best Regards,
    Sadiqh Ahmed

  • Create a new table style based on an existing table in a document

    Hi,
    In a document I'm working on, there is a specific table. It is made in the past by a colleague, and it has a very suitable format.
    Therefore I would like to use the layout of this table on all future tables in my document (or even in others).
    Is there an option to select my table, and create a new table style with it, so that I can use it over and over again? That would be very helpful.
    I'm working in MS Word, MS Office Professional Plus 2010, on a Windows 7 64-bit OS.
    Best regards, Sietske
    Ps.: I know
    a question like this was already asked, but the answer was quite dissatisfying (because it was not answering the question)
    Pps: Note that I'm now creating a new table style from scratch, so an answer to the above question is not that urgent, but it would still be nice to know for future use.

    you can  use format painter
    i hope that you already know about it.
    Nope, not the right answer. With Format Painter, you can copy the format of the table, but you can't create a new Table Style with it. I am looking for a solution as well.

  • Procedure to create new table using existing metadata

    Hi All,
    THis is what I want to achieve,
    I want to create procedure which will take a input parameter as name of a table lets say 'EMP',
    and this procedure will check whether that table exist or not?
    if exist then
    it will create a new table with name appending _dummy to existing table name (ex: new table will be EMP_DUMMY) ,
    and new table should have the same table structure ,index and constraint imposed on EMP table.
    NB: It should not be created using as select like create table EMP_DUMMY as select * from EMP where condition=false;
    Can any one please help me how to achieve this?

    Hi,
    you can use the DBMS_METADATA package
    declare
    cddl clob;
    ctable  varchar2(80):='EMP';
    cowner  varchar2(80):='HR';
    begin
    cddl:=dbms_metadata.get_ddl ('TABLE',ctable,cowner);
    cddl:=replace(cddl, 'CREATE TABLE "'||cowner||'"."'||ctable||'"','CREATE TABLE "'||cowner||'"."'||ctable||'_DUMMY"');
    dbms_output.put_line(substr(cddl,1,1200));
    execute immediate dbms_lob.substr(cddl,least(dbms_lob.getlength(cddl),32000));
    cddl:=dbms_metadata.get_dependent_ddl ('INDEX',ctable,cowner);
    cddl:=replace(cddl,'ON "'||cowner||'"."'||ctable,'ON "'||cowner||'"."'||ctable||'_DUMMY');
    execute immediate dbms_lob.substr(cddl,least(dbms_lob.getlength(cddl),32000));
    end;but you'll need to adapt (ex: existing contraint name etc)

  • Creating a new table, to replace an old one

    Hi experts;
    I'm looking for an advice about what I'm going to do.
    This is the situation;
    I got a production table with more than 1,000,000,000 of records.
    the queries to this table are too slow, and I decided to create a new table, to replace this one.
    But my doubts are:
    How can I create a new table including the same structure as the old one, and with some data.
    I got this query:
    Create new_table as select * from old_table
    where trans_year = '2012';
    I know with this I got the structure, but what about indexes?
    My other doubt is, to replace the old one, just I drop it, and rename the new one?
    This table belong to an oracle 9i DB.
    Thanks for your comments.
    Al

    >
    How can I create a new table including the same structure as the old one, and with some data.
    I got this query:
    Create new_table as select * from old_table
    where trans_year = '2012';
    I know with this I got the structure, but what about indexes?
    My other doubt is, to replace the old one, just I drop it, and rename the new one?
    This table belong to an oracle 9i DB.
    >
    You could export the table metadata and then import it as a renamed table. That would keep the indexes, triggers, constraints.
    But for one table it may be easier to just recreate the indexes and other objects.
    For the query you may want to disable logging of the INSERT.
    Create table new_table NOLOGGING as select * from old_table where trans_year = '2012';
    -- set the table back to logging mode
    ALTER table new_table LOGGING;Then you can drop the old table (if you already have a backup of it) and rename the new one to the old name.
    The create will perform much better with NOLOGGING but because it is not logged you will not be able to recover the data from the log files.
    So you should take a backup afterward.

  • I don't have the option to create a new table in my database

    Hi, I have SQL 2014, for some reason, a few weeks ago I was able to create a new table for my databases, now, I don't have the option to do so, all I get when I right click on tables is "Tables..." instead of "New Table", when I select
    "Tables..." it allows me to write my codes but it doesn't save except in a text files witch doesn't want to open when I want to resume my work.
    Is there any option in SQL to activate the "New Table" by right clicking on Tables? I have all the rights and permissions available to my use as it's my computer and my own server. 
    To fix the issue I tried
    -Re-installing SQL
    -Changed for 4 different versions
    -Allowing more than necessary permissions 
    -Making it public to use (it's only to test it, anyway, I'm in the learning phase)
    Any kind of help or advice will be welcome and much appreciated.
    Thank you!

    I don't know the reason why you are experiencing this, so what I am describing below are just some steps that you can take to diagnose the problem if it is related to a permissions issue.
    1. If you are not already on the computer where SQL Server is installed, login on that box and launch SQL Server Management Studio and run it as Administrator.
    2. Connect to the Server and open up the object explorer and expand the Security node that is directly under the Sever tab.
    3. Under logins, find your login, right-click properties and see what kind of server level permissions you have, and which databases you are mapped to and what kind of permissions you have on those.
    It may just be that this is not related to permissions at all, but I can't think of what that would be. To test whether it is a SSMS GUI problem or not, open up a query window and select a database on which you think you have permissions to create tables.
    Then create a test table using T-SQL, for example:
    create table dbo.MyTestTable( col1 int);

  • Is it possible to create a new table in the master database with SSMS ?

    Hello ,
    I have problems with this thread :
    http://social.msdn.microsoft.com/Forums/en-US/sqlexpress/thread/5153c43b-7844-41c4-a414-d14730abe435/
    If no user database has been created , in SSMS , we can see only the 5 system databases ( master, msdb , tempdb... ).
    Logically , the user should connect automatically on the Master database ( if the user is the same as this used to install a new SQL Server instance, this user should be sysadmin that's to say he/she has all possible permissions and especially dbcreator ).
    Is it true that it is impossible to create a new table on the master database ?
    I have done many researches about this possibility , all I have found is the advice : don't touch to the master database. This database is used to store critical information about the instance and its user databases. Even in the last book of Kalen Delaney
    about SQL Server 2012 Internals , I have found nothing clear about the creation of tables in this database ( and what about the other system databases ? I am excluding tempdb ).
    If someone has an idea about this thread and my questions , I would be thankful for a reply on this thread or on the related thread in the SQL Server Express Forum ( with my poor written English , I am not sure to have poster in a correct and understandable
    way ).
    If you think that this thread is not in the good forum , a moderator of this forum can move this related thread ( I have not done the move as I am not sure which is the good forum Database Engine or Transact-SQL ... )
    Thanks beforehand and have a nice day.
    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.

    >>Logically , the user should connect automatically on the Master database ( if the user is the same as this used
    to >>install a new SQL Server instance, this user should be sysadmin that's to say he/she has all possible permissions and >>especially dbcreator ).
    If you add the current user during the installation you can have it as system admin , or you can add him/her later on
    in SQL Server. BTW regarding dbcreator I have wrote some blog , need to read... :-)
    http://sqlblog.com/blogs/uri_dimant/archive/2010/09/02/be-careful-to-grant-dbcreator-server-role-to-the-user.aspx
    You can (if you have needed permissions) to create objects in master database, usually I create objects for instance maintenance (like rebuild indexes...) 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to create a new table based out of old data rows

    Hi All,
    How to create a new table based out of old data rows. Also how can we find out the DBF for different users in a database?
    Saqib

    Not very clear what you need. I'll try to interpret...
    How to create a new table based out of old data rowsIf this means how to create a table from an existing one, then you can do :
    SQL> create table <new table> as select * from <old table>;
    if you need a subset of rows you can add a where clause.
    how can we find out the DBF for different users in a database?Here I need some more clarification. What do you mean exactly ?

  • How to create a new Table

    Hi,
    I need to create a new Table from null,
    is the example in the javadoc of com.sun.rave.web.ui.component.TableBase ok ?
    If yes where are the Messages and Clean classes ?
    Thanks.

    Thanks, found : Creator Tip: Displaying two dimensional array in the table component

Maybe you are looking for

  • Two different Icloud accounts but want to share only one?

    Hello everyone, Alright, I just swiched to the new iphone, so i put everything from my old phone to my new phone. BUT here is the problem, i cant access the familys icloud account. they all have the same one, but i am stuck with one odd one:/. so now

  • How to get amf headers?

    Hi I have set up communication between Actionscript and .NET WCF using amf. And the communication has worked fine using NetConnection. I have sent and recevied data in both directions. And sending headers from actionscript is no problem but when i se

  • How to run mass activity for DS 0FC_INVDOC_00 and activate 2710 event

    Hi, I am trying to extract data from DS 0FC_INVDOC_00 it gets me 0 records.I read in the form that to get the records i have to run the Mass Activity type 2620 and for daily processing of invoicing, you have to activate 2710 event.Can anyone please l

  • My BB 8900 keyboard problem

    Good Morning, Im having a problem with keyboard, some letters ar not properly operating like the backspace and the key pad for letter K and the power on key. I dont remember any circumstances that i drop it or mis handled my BB, just 1 night it start

  • IDE:  Child movieclip timeline changes don't show in parent timeline?

    Why does a child movieclip only show the first frame within the IDE, regardless of where you are in the parent timeline? If you throw a movieclip with 25 frames onto the main timeline, which also has 25 frame, you don't see the nested movieclip's fra