Oracle jdbc creating a table, sequence and trigger

I'm trying to create a table with a sequence and with a trigger for that sequence. When I do this within Oracle Express edition I have the following SQL statements. Which DO run correctly inside Oracle Express using the same user I log in with JDBC.
CREATE table "TEST" (
"ID" NUMBER(10) NOT NULL,
"NAME" VARCHAR2(20),
constraint "TEST_PK" primary key ("ID")
CREATE sequence "TEST_SEQ"
CREATE trigger "BI_TEST"
before insert on "TEST"
for each row
begin
if :NEW."ID" is null then
select "TEST_SEQ".nextval into :NEW."ID" from dual;
end if;
end;
So now what I do is put each of these into a List of Strings and execute 1 by one like this:
List<String> commands = new ArrayList<String>(4);
commands.add("Create table ...");
commands.add("Create sequence ...");
commands.add("Create trigger...");
st = con.createStatement();
for (String command : commands) {
st.execute(command);
etc...
But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"
It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?
TIA

SproketBoy wrote:
But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"Keep in mind: Oracle is not lying to you.
>
It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?No, DDL commands cause an explicit commit. As soon as you invoke them, the change is permanent. If it was a rights problem, you'd get a different ORA error stating that, it won't silently fail.
Lets not assume it is anything difficult, perhaps there is simply a typo in a name somewhere?

Similar Messages

  • Creation of sequence and trigger for each table!!!!!!!1

    Hi
    I am new to trigger and Sequence field. In one of my database we have many tables with fields for specifing ID numbers. Iam planning to insert the ID field with help of a Sequence and trigger...that trigger fires by adding the sequence value from the dual table. Now the point is here we r having around *60* table with ID field. And i am planning use the above process for each table by creating sequences and trigger for each table.
    Will this affects the performance of database.
    Is there any other option other than the above process, I mean other than creating sequences and trigger for each table.
    PLzz help to resolve this issuee......
    Shiyas
    Edited by: user13170361 on Jun 7, 2010 12:37 AM

    Tiger, I didn't mind about your comment, but the point is try to use
    select NVL(max(a) + 1,1) into i from p1_temp;This line in your trigger code and see what is happening. The problem is with your trigger. You are using group by function and you will not get no_data_found !
    For more help, this is some modification of your code.
    SQL> create table p1_temp (a number(10) primary key, b number(10));
    Table created.
    SQL> create or replace trigger trg_p1_temp
      2  before insert on p1_temp for each row
      3  declare
      4  i number(10);
      5  begin
      6  begin
      7  select NVL(max(a) + 1,1) into i from p1_temp;
      8  exception
      9  when no_data_found then
    10  i := 1;
    11  end;
    12  :new.a := i;
    13  end;
    14  /
    Trigger created.
    SQL> insert into p1_temp(b) values (1);
    1 row created.
    SQL> insert into p1_temp(b) values (2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from p1_temp;
             A          B
             1          1
             2          2
    SQL> Edited by: Saubhik on Jun 7, 2010 2:30 AM

  • How to Create a table with numeric trigger for INSERT

    Let me start off by saying that I am very new to DBMS.
    I need to create a Table with INSERT Trigger. I am not exactly sure if I need to have a BEFORE ot AFTER insert trigger but leanning towards AFTER.
    I have a Java code that will need insert a row each time that piece of code is executed. I would also like an oracle trigger to insert a unique numeric value (REC_ID) for that that record.
    I am totally lost and I am not sure how to go about it. Can you point me to the right direction?
    Basically my table will have the following 3 columns
    REC_ID NUMBER NOT NULL (uniquie value inserted by the trigger)
    PROPERTY_NAME VARCHAR2(100 BYTE)
    PROPERTY_VAL VARCHAR2(100 BYTE)
    Thank you in advance
    Eric

    Take a look at the following: Also please do a search in this forum.
    http://infolab.stanford.edu/~ullman/fcdb/oracle/or-jdbc.html

  • Suppress auto sequence and trigger DDL for surrogate keys?

    Is there a way to suppress trigger and sequence creation for surrogate keys when export to DDL file?
    I know most of the time the automatic sequence and trigger creation is welcome and very handy.
    However I'm migrating from an old Designer model and there only the needed sequences are created.
    They have a different name and trigger logic is custom (and  generated outside designer).
    There is a lot of package code depending on this. So I prefer to create and use different sequences.
    Is there a way to achieve this? Any tips are welcome.Create

    Hi,
    Note that generating the DDL for Oracle 12c means that it will attempt to use your Oracle 12c Physical model.  So if you normally use Oracle 10g or 11g, you will find that any details from your Oracle 10g or 11g Physical Model will not be included.  So this approach may have other implications for you.
    If you are not using Oracle 12c, there are some relevant properties on the Auto Increment tab of the Relational Model properties dialog for the Column which may help:
    Sequence Name - allows you to specify the name of the Sequence (which can be the name of a Sequence defined in the relevant Physical Model).
    Trigger Name - allows you to specify the name of a Trigger (which can be the name of a Trigger that is defined for the Table in the Physical Model).
    Generate Trigger - unsetting this will stop the Trigger being generated.
    David

  • Sequencing and Trigger on Oracle 9i lite database

    We created a schema (TESTSCHEMA) on Oracle 8.1.7 Enterprise edition and have a created a trigger which will use the sequence object to generate primary key for the table (TEST_TABLE)
    Sequence creation:
    CREATE SEQUENCE TESTSCHEMA.TEST_TABLE_SEQUENCE START WITH 6000 INCREMENT BY 1 MINVALUE 6000 MAXVALUE 6999 NOCACHE NOCYCLE NOORDER ;
    Trigger creation:
    CREATE OR REPLACE TRIGGER TEST_TABLE INSERT BEFORE INSERT ON TEST_TABLE FOR EACH ROW
    DECLARE
    pkValue NUMBER;
    BEGIN
    pkValue := 0;
    Select TEST_TABLE_SEQUENCE.NextVal into pkValue from dual;
    :NEW.TEST_KEY := pkValue;
    END TEST_TABLE_INSERT;
    We have created a snapshot of the schema on mobile server, synchronized the data with the client (Win32 for testing purpose).
    The trigger works fine on the server, but when I run the same query on the lite database with msql it gives me an error:
    [POL-3221] null key in primary index
    I was wondering if Sequence generation and Triggers are supported on Oracle 9i lite database ? Or am I missing out something ??
    Any information/ help is appreaciated
    Thanks
    Neeraj

    You can't use SAVEPOINT / ROLLBACK TO SAVEPOINT statements in the database trigger:
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-04092: cannot ROLLBACK in a trigger
    I am not sure what you need exactly, but you can try this:
    Simulating ROLLBACK TO SAVEPOINT Behavior in a Database Trigger
    http://www.quest-pipelines.com/pipelines/plsql/tips02.htm#JUNE
    Regards,
    Zlatko Sirotic

  • Sequence and trigger

    Hello,
    Ia have created a Sequence and a trigger
    The Sequence ïs:
    CREATE SEQUENCE "WABO"."WABO_VERG_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 ORDER NOCYCLE;
    The trigger is:
    create or replace
    TRIGGER WABO.WABO_VERGUNNING_TRIC
    BEFORE INSERT ON WABO.WABO_VERGUNNING FOR EACH ROW
    WHEN (new.WABO_ID IS NULL) BEGIN
    SELECT WABO_VERG_SEQ.NEXTVAL INTO :new.WABO_ID FROM dual;
    END;
    When I insert a row in the table the sequence counter is 21 and it's stay's 21 even when I insert a new row
    When I cal the DDL it's showes me this
    CREATE SEQUENCE "WABO"."WABO_VERG_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 ORDER NOCYCLE;
    What am I doning wrong.
    Thanks

    Solved

  • Export tables, sequence, and package question

    Hi all,
    I've export table like: exp username/password file=export.dmp log=export.log tables=A statistics=none.
    The export statement above just export only the table "A" structure not the table "A" data. So, how can I move all the data from table "A" to table "B".
    How do I export the sequence, and package and its data also?
    Thank you very much
    Kevin

    Can you create a DBlink in order to do the insert into B select * from A.
    Also, you can use the SQL*Plus Copy command.
    Here are some links for COPY command:
    <br>Copying Data
    <br>copy command
    <br>copy command vs sql*loader
    <br><br>
    Here is a link for moving code:
    <br>exporting packages,function etc. from one user to another.

  • Using interface builder to create a table view and add a cell

    So I am using interface builder to make a table view. Should be easy. I drag a table view controller to my view, then it seems I should be able to drag a table view cell to the table view but it won't let me drop it down. If I do it in the documents window it just replaces the table view with a cell. Seems like this shouldn't be hard, but it's one of those things that should take 2 seconds but I have been messing with it for hours. It seems like most of the examples I have looked at in the same code don't use iB so I haven't found a good reference. If somebody can point me in the write direction let me know.

    I struggled a bit too. Here's what I did on my recently completed app. I used IB to create the basic view and add the table. That's it. Then ensure your UIViewController based class implements the UITableViewDelegate and UITableViewDataSource protocols. Your cells will come from those methods, not anything you do in IB.
    If you're creating a set of screens that just have tables that allow you to navigate up and down through the data then IB isn't worth using at all.
    Just have your views extends UITableViewController and follow some of the supplied table based example apps.
    I rewrote my first app 3 times as I slowly figured all of this out.
    Hope that helps.

  • Auto number by sequence and trigger - issue

    Hi,
    i need to insert auto number in one of the column of my table, and i tried like the following way..
    CREATE TABLE STOP_TRACKING
      ID                    NUMBER                           primary key,
      MSISDN                NUMBER                  NOT NULL,
      TIME_STAMP            DATE                    DEFAULT SYSDATE,
      STOP_TRACKING_RESULT  NUMBER,
      REQUEST_ID            VARCHAR2(60 BYTE)
    TABLESPACE SYSTEM
    PCTUSED    40
    PCTFREE    10
    INITRANS   1
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                FREELISTS        1
                FREELIST GROUPS  1
                BUFFER_POOL      DEFAULT
    LOGGING
    NOCACHE
    NOPARALLEL;
    COMMENT ON COLUMN STOP_TRACKING.STOP_TRACKING_RESULT IS 'IF RESULT ID "0" - OK AND IF RESULT ID "1" - NOT OK';
    create sequence seq_autonumber;
    CREATE OR REPLACE TRIGGER trg_autonumber
    BEFORE INSERT ON STOP_TRACKING
    FOR EACH ROW
    WHEN (new.id IS NULL)
    BEGIN
      SELECT seq_autonumber.NEXTVAL
      INTO   :new.id
      FROM   STOP_TRACKING;
    END;
    /when i execute the create trigger sql in toad sql editor am getting a pop up saying
    >
    variable name:NEW
    Type: drop down list ...here i tried almost relevant data types, int,long,....
    Value:...here i entered 1
    and clicked ok...and got the error as
    ORA-01036: illegal variable name/number
    >
    what could be issue?
    Edited by: Aemunathan on Nov 22, 2009 2:55 PM

    I just copy pasted your code.
    Works just fine.
    I believe you issue is realed to TOAD rather than pl/sql.
    Would have loved to help you but i use pl/sql developer.
    However if possible send a screen shot.
    Cheers!!!
    Bhushan

  • Oracle JDBC: using getString() vs getRAW() and setString() vs setRAW()  for RAW colum

    When extracting a column from an OracleResultSet that has type RAW(16) in the
    database or when binding a parameter for the RAW database column, is there any
    pitfalls with using getString() / setString() methods as opposed to getRAW() /
    setRAW() ? (for example, character-set-related ones).
    We need to pass the values in the RAW columns through URLs and have to convert
    them to Strings before doing this. However, stringValue() method of the RAW
    object creates a string that we could not easily restore to the "same" RAW
    object (the only way that we found was to use the HEXTORAW() method in all
    queries where that RAW value needed to be bound). Some folks however just treat
    RAW values as Strings in their Java code (with getString/setString methods), and
    so we were wondering if this is acceptable or there are any problems with this
    simpler approach. If it IS acceptable, why would anyone use RAW Java objects at
    all?
    Thanks,
    Menon:)

    When extracting a column from an OracleResultSet that has type RAW(16) in the
    database or when binding a parameter for the RAW database column, is there any
    pitfalls with using getString() / setString() methods as opposed to getRAW() /
    setRAW() ? (for example, character-set-related ones).
    We need to pass the values in the RAW columns through URLs and have to convert
    them to Strings before doing this. However, stringValue() method of the RAW
    object creates a string that we could not easily restore to the "same" RAW
    object (the only way that we found was to use the HEXTORAW() method in all
    queries where that RAW value needed to be bound). Some folks however just treat
    RAW values as Strings in their Java code (with getString/setString methods), and
    so we were wondering if this is acceptable or there are any problems with this
    simpler approach. If it IS acceptable, why would anyone use RAW Java objects at
    all?
    Thanks,
    Menon:)

  • JDeveloper 10g Creating a new record with trigger sequence primary key

    Hi there, I'm sorry to post this incredibly simple question and I'm sure that someone must have answered this on this forum before but the searching of this site is incredible slow and painful and after 30 mins I can't find help.
    I am using a struts Data Action to create a new record in the database and then being forwarded to an edit page where I can enter the new details. Then when the details are entered I am clicking an update button and returning to a browse screen where I can either commit the change to the database or rollback. Sounds pretty simple but I am really struggling with trying to get the trigger of the number sequence to work properly.
    Ideally I would like to click the create new record button and then the primary key/triggered sequence number is already displayed on the empty form...
    ... but if this is too tricky or not possible then I would like the user to either not enter any value in the key field (which currently causes error - JBO-27014: Attribute PoNo in PO_SYS_MODULE.PoSystemView1 is required) OR the user enters a number and the trigger overwrites this number with the next in the sequence.
    I can enter a new record if I look in the manager console and see the next number in the sequence and then create the record using this number and then click commit twice, as the first time I get the error: JBO-25019: Entity row of key oracle.jbo.Key[154 ] not found in PoSystem. Or if I enter a value 5 times greater than the next in the sequence I have to click the commit button 5 extra times to get the sequence to match the input.
    I hope that this lengthy explanation fills you in on my problem, there must be a simple solution to this and I will be VERY grateful to anyone who can help me.
    Many thanks
    Ben Sayers (clearly a newbie)

    Hi,
    ADF Business Components handles this for you - unless yo prefer doing this manually. In the Entity Object, set the PK attribute's type to DBSequence. Then create a database sequence and use a database trigger to add the sequence value on insert
    Frank

  • Custom Transformations Scripts: Creating sequences and synonyms

    Is there a way in Data Modeler to script the creating process of sequences and synonyms. I've already found how to create columns in a table, but is it also possible to create sequences and synonyms for tables? I've looked it up in the XML Metadata, but I didn't found where I was looking for? Can anybody help me?

    no documentation, it should be possible:
    seq = model.getStorageDesign().getSequenceSet().createSequence();
    syn =  model.getStorageDesign().getSynonymSet().createSynonym();make sure physical model is open and that model is set as physical model to your relational model. That's for Oracle
    Philip

  • Differences between Oracle JDBC Thin and Thick Drivers

    If any body is looking for this information...
    ============================================================
    I have a question concerning the Oracle JDBC thin vs. thick drivers
    and how they might affect operations from an application perspective.
    We're in a Solais 8/Oracle 8.1.7.2 environment. We have several
    applications on several servers connecting to the Oracle database.
    For redundancy, we're looking into setting up TAF (transparent
    application failover). Currently, some of our apps use the Oracle
    <B>JDBC thin</B> drivers to talk to the database, with a connection
    string that like this:
    <B> jdbc:oracle:thin:@host:port:ORACLE_SID </B>
    In a disaster recovery mode, where we would switch the database
    from one server to another, the host name in the above string
    would become invalid. That means we have to shut down our application
    servers and restart them with an updated string.
    Using the Oracle <B>OCI (thick)</B> driver though, allows us to connect
    to a Net8 service instead of a specific server:
    <B> jdbc:oracle:oci8:@NET8_SERVICE_NAME </B>
    Coupled with the FAILOVER=ON option configured in Net8, it is
    then possible to direct a connection from the first server to
    the failover database on another server. This is exactly what
    we would like to do.
    My question is, from an application perspective, how is the Oracle
    thick driver different from the thin driver? If everything
    else is "equal" (i.e. the thick driver is compatible with the
    app servers) would there be something within the the thick/OCI
    driver that could limit functionality vs. the thin driver?
    My understand, which obviously is sketchy, is that the thick
    driver is a superset of the thin driver. If this is the case,
    and for example if all database connections were handled through
    a configuration file with the above OCI connection string, then
    theoretically the thick driver should work.
    ============================================================
    <B>
    In the case with the Oracle, they provide a thin driver that is a 100% Java driver for client-side use without the need of an Oracle installation (maybe that's why we need to input server name and port number of the database server). This is platform indipendent, and has good performance and some features.
    The OCI driver on the other hand is not java, require Oracle installation, platform dependent, performance is faster, and has a complete list of all the features.
    </B>
    ========================================================
    I hope this is what you expect.
    JDBC OCI client-side driver: This is a JDBC Type 2 driver that uses Java native methods to call entrypoints in an underlying C library. That C library, called OCI (Oracle Call Interface), interacts with an Oracle database. <B>The JDBC OCI driver requires an Oracle (7.3.4 or above) client installation (including SQL*Net v2.3 or above) and all other dependent files.</B> The use of native methods makes the JDBC OCI driver platform specific. Oracle supports Solaris, Windows, and many other platforms. This means that the Oracle JDBC OCI driver is not appropriate for Java applets, because it depends on a C library to be preinstalled.
    JDBC Thin client-side driver: This is a JDBC Type 4 driver that uses Java to connect directly to Oracle. It emulates Oracle's SQL*Net Net8 and TTC adapters using its own TCP/IP based Java socket implementation. <B>The JDBC Thin driver does not require Oracle client software to be installed, but does require the server to be configured with a TCP/IP listener. Because it is written entirely in Java, this driver is platform-independent.</B> The JDBC Thin driver can be downloaded into any browser as part of a Java application. (Note that if running in a client browser, that browser must allow the applet to open a Java socket connection back to the server.
    JDBC Thin server-side driver: This is another JDBC Type 4 driver that uses Java to connect directly to Oracle. This driver is used internally by the JServer within the Oracle server. This driver offers the same functionality as the client-side JDBC Thin driver (above), but runs inside an Oracle database and is used to access remote databases. Because it is written entirely in Java, this driver is platform-independent. There is no difference in your code between using the Thin driver from a client application or from inside a server.
    ======================================================
    How does one connect with the JDBC Thin Driver?
    The the JDBC thin driver provides the only way to access Oracle from the Web (applets). It is smaller and faster than the OCI drivers, and doesn't require a pre-installed version of the JDBC drivers.
    import java.sql.*;
    class dbAccess {
    public static void main (String args []) throws SQLException
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@qit-uq-cbiw:1526:orcl", "scott", "tiger");
    // @machineName:port:SID, userid, password
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
    while (rset.next())
    System.out.println (rset.getString(1)); // Print col 1
    stmt.close();
    How does one connect with the JDBC OCI Driver?
    One must have Net8 (SQL*Net) installed and working before attempting to use one of the OCI drivers.
    import java.sql.*;
    class dbAccess {
    public static void main (String args []) throws SQLException
    try {
    Class.forName ("oracle.jdbc.driver.OracleDriver");
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:oci8:@qit-uq-cbiw_orcl", "scott", "tiger");
    // or oci7 @TNSNames_Entry, userid, password
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
    while (rset.next())
    System.out.println (rset.getString(1)); // Print col 1
    stmt.close();
    =================================================================

    Wow, not sure what your question was, but there sure was a lot of information there...
    There really is only one case where failover occurs, and it would not normally be in a disaster recovery situation, where you define disaster recovery as the obliteration of your current server farm, network and concievably the operational support staff. This would require a rebuild of your server, network etc and isn't something done with software.
    Fail over is normally used for high availablity that would take over in case of hardware server failure, or when your support staff wants to do maintenance on the primary server.
    Using the thin and thick driver should have ZERO affect on a failover. Transparent failover will make the secondary server the same IP as the primary, therefore the hostname will still point to the appropriate server. If you are doing this wrong, then you will have to point all your applications to a new IP address. This should be something that you tell your management is UNACCEPTABLE in a fail-over situation, since it is almost sure to fail to fail-over.
    You point out that you are providing the TNSNAME, rather than the HOSTNAME when using the thick driver. That's true within your application, but that name is resolved to either a HOSTNAME, or IP ADDRESS before it is sent to the appropriate Oracle server/instance. It is resolved using either a NAME server (same as DNS server but for Oracle), or by looking at a TNSNAMES file. Since the TNSNAMES files profilerate like rabbits within an organization you don't want a fail over that will make you find and switch all the entries, so you must come up with a fail over that does not require it.
    So, the application should not be concerned with either the hostname, or the IP address changing during fail over. That makes use of the thin or thick client acceptable for fail over.
    Don't know if this will help, but this shows the communication points.
    THIN DRIVER
    client --> dns --> server/port --> SID
    THICK DRIVER
    client --> names server --> dns --> server/port --> SID
    client --> tnsnames     --> dns --> server/port --> SID

  • Access Stored Package and Trigger

    I first connect to Oracle using my user name (such as TESTER). Once I get connected, I create a package named pkg_test. If I understand it correctly that Oracle will stored it in DBA_SOURCE table, not in my schema. Now, I have some questions regarding to the privilege to access the package.
    1) When I want to access the package after I connect to Oracle, I will directly use it without prefix, that is, pkg_test.sp_get_text()... But when other users want to access it, do they need to use the prefix TESTER, that is, TESTER.pkg_test.sp_get_text()?
    2) After I connect to Oracle, I create a table named test_tab. This table will be accessible by other users. Then I create a trigger on the table.
    create or replace trigger trig_test
    for insert on TESTER.test_tab
    Do I need to use the prefix TESTER in the trigger so that it will be accessible to other users?
    Thanks
    Scott

    scottjhn wrote:
    If I understand it correctly that Oracle will stored it in DBA_SOURCE table, not in my schema. Now, I have some questions regarding to the privilege to access the package.The source will be stored in the data dictionary, yes (it will also be visible in ALL_SOURCE and USER_SOURCE). But the object itself will be stored in the TESTER schema.
    1) When I want to access the package after I connect to Oracle, I will directly use it without prefix, that is, pkg_test.sp_get_text()... But when other users want to access it, do they need to use the prefix TESTER, that is, TESTER.pkg_test.sp_get_text()?By default, yes. Oracle will try to resolve objects without schema qualifiers using objects in the current schema.
    You can change this default by creating a public synonym for PKG_TEST or by creating a private synonym in each user's schema for PKG_TEST or by running
    ALTER SESSION SET current_schema = 'TESTER' when logged in as a different user
    2) After I connect to Oracle, I create a table named test_tab. This table will be accessible by other users. Then I create a trigger on the table.
    create or replace trigger trig_test
    for insert on TESTER.test_tab
    Do I need to use the prefix TESTER in the trigger so that it will be accessible to other users? No, you don't need to use the schema qualifier if TESTER will be the owner of the trigger.
    Justin

  • What is difference between table space and shchema

    what is difference between table space and shchema ?

    784633 wrote:
    so each user has it own space of tables - schema ?yes, but let's clarify a bit ....
    The "schema" is the collection of all objects owned by a particular user. So if user SCOTT creates two tables, EMP and DEPT, and a view EMP_RPT, and a procedure GET_MY_EMP, those objects (tables, views, procedures) collectively make up the SCOTT schema.
    Those objects will be physically stored in a tablespace.
    A tablespace is a named collection of data files. So tablespace USERS will be made up of one or more data files. A specific datafile can belong to one and only one tablespace. If a tablespace has more than one data file, oracle will manage those files as a collection invisible to the application - much like the OS or disk subsystem handles striping across multiple physical disks.
    A specific object in the SCOTT schema can exist in only one tablespace, but not all objects of the schema have to be in the same tablespace. Likewise a tablespace can contain objects from multiple schemas.
    and can one user to access tables of other users?As others have said - FRED can access tables belonging to SCOTT as long has SCOTT has granted that access to FRED.

Maybe you are looking for