EVT_, SM and SMP_ tables in a user schema
I found some tables and indexes in a user schema that this user hasn't created. 15 tables have a prefix EVT_, about 35 start with SM and about 30 have the prefix SMP_ . It seems they are some type of tables created by Oracle. What are they for and can they be deleted?
Thanks in advance!
Best regards,
Tzonka
Please see the list of some of them:
TABLE TABLESPACE
EVT_CARRIER_CONFIGURATION USERS
EVT_DEST_PROFILE USERS
EVT_HISTORY USERS
EVT_INSTANCE USERS
EVT_MAIL_CONFIGURATION USERS
EVT_MONITOR_NODE USERS
EVT_NOTIFY_STATUS USERS
EVT_OPERATORS USERS
EVT_OPERATORS_ADDITIONAL USERS
EVT_OPERATORS_SYSTEMS USERS
EVT_OUTSTANDING USERS
EVT_PROFILE USERS
EVT_PROFILE_EVENTS USERS
EVT_REGISTRY USERS
EVT_REGISTRY_BACKLOG USERS
PLAN_TABLE USERS
SMACTUALPARAMETER_S USERS
SMAGENTJOB_S USERS
SMARCHIVE_S USERS
SMBREAKABLELINKS USERS
SMCLIQUE USERS
SMCONFIGURATION USERS
SMCONSOLESOSETTING_S USERS
SMDATABASE_S USERS
SMP_AD_ADDRESSES_ USERS
SMP_AD_DISCOVERED_NODES_ USERS
SMP_AD_NODES_ USERS
SMP_AD_PARMS_ USERS
SMP_AUTO_DISCOVERY_ITEM_ USERS
SMP_AUTO_DISCOVERY_PARMS_ USERS
SMP_BLOB_ USERS
SMP_BRM_ACTIVE_JOB_ USERS
SMP_BRM_CHANNEL_DEVICE_ USERS
SMP_BRM_DEFAULT_CHANNEL_ USERS
SMP_BRM_RC_CONNECT_STRING_ USERS
SMP_BRM_SAVED_JOB_ USERS
SMP_BRM_TEMP_SCRIPTS_ USERS
And some indexes:
TABLE INDEX TABLESPACE
EVT_CARRIER_CONFIGURATION SYS_C006660 USERS
EVT_MONITOR_NODE SYS_C006662 USERS
EVT_OPERATORS SYS_C006664 USERS
EVT_PROFILE SYS_C006668 USERS
... etc.
Hi,
>>What are they for
As I know SMP_ and EVT_ tables are used by Enterprise Manager, and comprise the Enterprise Manager Repository. When logging into Enterprise Manager, always log in as the repository owner.
>>can they be deleted?
if your oem repository owner is different from the user in which these tables are listed then the objects can be dropped
Cheers
Similar Messages
-
Search script generator for all objects and data (!) from a user/schema ?
Is there a way to create a script which (when run) creates all the existing
TABLES; INDEXES, KEYS and DATA for a specified user/schema ?
This (PL-)SQL script should contain all INSERTS for the currently existing rows of
all the TABLEs.
When I use e.g. export to Dumpfile I have at first find all TABLEs and components
which I want to dump. This is rather uncomfortable.
I just want to specify the user name similar to
createscript user=karl@XE outfile=D:\mydata\myscript.sql
Is this somehow possible ?So that I understand your requirements exactly, are you asking for your script to ...
1/ export from database A the entire schema of a specified user
2/ drop all objects owned by that user in database B
3/ import the objects from database A into database B
If so, it sounds to me that a shell script that does a schema level export as Nicholas suggested, and then drops the user from database B using the cascade keyword (e.g. drop user username cascade), recreates the user and then imports the export file into B should do the trick.
I don't think searching for individual tables and creating the statements to recreate them is the best idea.
Hope that helps
Graham -
Create user/schema is script, then tables for that user/schema
Hi;
First off, if I phrase this a little wrong - I'm from the Sql Server world and still trying to totally understand Oracle.
I have a schema (.sql file) that creates my database fine. But what I would liek to add to the .sql schema is for it to create a user and then place all the tables, indexes, sequences, and triggers in as belonging to that created user.
This way we can tell people to log in as sysop and run the script to create the schema rather than create the user, log in as the user, then run the script.
What do I need to add?
thanks - daveHi;
I have tried:
CREATE USER DAVE IDENTIFIED BY password;
CONNECT DAVE/password AS SYSDBA
I have also tried:
CONNECT DAVE/password AS SYSTEM
CONNECT DAVE AS SYSDBA
CONNECT DAVE
In all cases ApplicationExpress says it does not recognize the CONNECT command. Should I do something different? What I want to accomplish is that all subsequent commands in the script creating tables, indexes, etc are assigned to the user/schema DAVE.
thanks - dave -
Edit tables in other user schema
Hello all,
Is there a way to allow a user to edit tables for another user?? For example, suppose user A has tables X, Y and Z. I need user B to be able to edit those tables in SQL Developer.
I have granted user B everything on A's tables, but once user B log to SQL Developer-> Other Users -> Tables. Right click any table and choose edit, an error message is displayed "The database user has insufficient privileges for the given operation"
I am kindly asking for help regarding this issue.
Regards,
EmadI do believe so. I have tried to grant select any dictionary to the user and he still can not edit the tables in the other schema.
I do hope Oracle solve this if it is a bug. -
Hi ,
Is it possible to have my source and target tables in the Same achema.......will it have any performance issues or some other issues in our ODI.......
I would like to know whether it works well or not .........
( To my understanding it wont have any issues ......But I am not 100 % sure on my judgement)
Thanks
AKYes, you're correct.
Just be sure about you load strategy, it means, if you need only to insert use the KM Control Append, but if need update too, try the IKM Oracle Incremental Update... I believe that will work better for millions of lines.
Anyway be sure that your database has the necessary tablespaces to manage huge data volume. -
How to export and Import table of another user from user system using expdp
Hi All,
How to export a table 'scott.emp' from system user.
expdp system/password directory=expdp dumpfile=scott_emp.dmp ???? ?? tables=emp ??????????????????????????
thank you
---------------------------------------------------------- Posting solution here to make needed users not to scroll down ------------------------------------------------------
Finally I got it right!!!
Task :- Export table_1 of schema_a from database db1 and Import it to schema_b of database db2 as user other than schema owner
Solution :-
expdp system/pwd directory=expdp tables=schema_a.table_1 dumpfile=schema_a.table_1.dmp logfile=expdp_schema_a.table_1.log
impdp system/pwd directory=expdp tables=schema_a.table_1 dumpfile=schema_a.table_1.dmp logfile=impdp_schema_a.table_1.log remap_schema=schema_a:schema_b remap_tablespace=table_1_tablespace:schema_b_tablespace
Thank You All
Edited by: Ven on Mar 9, 2011 7:52 AMJust a example
SQL> $expdp system/sys directory=data_pump_dir dumpfile=tests.dmp tables=scott.emp
Export: Release 11.2.0.1.0 - Production on Tue Mar 8 10:39:57 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_TABLE_01": system/******** directory=data_pump_dir dumpfile=tests.dmp tables=scott.emp
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."EMP" 8.570 KB 14 rows
Master table "SYSTEM"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is:
C:\APP\MAZAR\ADMIN\ACEME\DPDUMP\TESTS.DMP
Job "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at 10:40:01
SQL> -
Allowing a user to create/drop tables in another users schema
We have a central shared schema (TEAM). So we can monitor who is doing what users have there own login(USER1, USER2...). Is there a way to allow a user to create/drop objects in another user.
I.e.
SQL> connect USER1
SQL> create team.table1(col1 char(1));
SQL> drop table team.table1:
How can this be set up?
BenHere is what you can do, If you want to keep track of what users are doing.
Open the glogin.sql file and set the spool like this
spool /oracle/audit/SID_&_user.logEverytime user logs in it will be populated and you will be able to see who is doing what.
You can remove the write permission on glogin.sql so that no one can modify it.
You also need to create a script like this, which would rename it every time same user would login.
#!/bin/ksh
time=`date +"%b"_"%d"_"%H"_"%M"`
##you need to pass some more variables and while loop to include all the users## ( This is just for an example)
if [ -f /oracle/audit/SID_SYS.log ]
then
mv /oracle/audit/SYS.log /oracle/audit/SYS.log.$time
fiEdit the glogin.sql file with this script information like this
host /oracle/audit/file.kshHope this helps, if you need more information let me know. -
How many users/ schemas can we create in an oracle database?
How many users can we create in an oracle database? Or how many users can oracle handle?
Problem-
I have to store information of ontologies (I will use countries instead) in db.
I have to store information regarding countries.
I have 13 tables in all to maintain for each country.
Now there are two approaches:
1) keep only 13 tables. Have an extra column in each table to indicate that a particular
row stores information for which country.
2) create a new user/ schema for each country. So we can get rid of the extra column
needed in 1st approach.
I have used the second approach. This is because number of entries in each table for a
given country will be large.
So initially when the s/w is installed I create a central-user. Each time data for new
country has to be entered central-user creates a user/ schema, and creates tables for
this user/ schema. The central user can access the tables of all the countries by
country_name.table_name. By this approach I believe searching would be easy.
If there is any flaw in my approach kindly mention it.
Thank youThere is no (practical at least) limit to the number of users & schemas you can have in Oracle.
Your approach, however, is not going to scale nearly as well as the first option you outlined (adding a column). You are going to end up caching every possible variation of the various queries you're going to be executing because you will be referring to so many different tables, which is going to mean that you are doing a lot more work to parsing statements and generally churning through the shared pool. If you create enough users, you're liable to start hitting ORA-04030 errors because your shared pool is so fragmented.
Additionally, you're likely going to end up with a whole lot of dynamically generated SQL to accommodate new schemas getting added over time which is going to cause you even more pain. Figuring out dynamically what table to join in is a heck of a lot more difficult for the programmer to write and for the database to handle than simply passing in a different country code.
If you're concerned about having too much data, you can have your cake and eat it to by adding the country column and partitioning the tables based on country.
Justin
One other item I forgot to mention is maintainability. Having dozens or hundreds of "identical" schemas makes maintenance a huge pain because something like adding a new column now requires dozens or hundreds of separate DDL statements. You're almost guaranteed that some schema isn't going to be in sync-- it's going to miss a column or miss an index, etc.
Message was edited by:
Justin Cave -
How to copy all tables, triggers, etc from one user schema to another
Hello everybody!
I am searching for a QUERY or Stored Procedure to copy the tables of one user schema to another schema.
Should look kind of: Copy (Select * from all_objects where owner = 'UserIwantToCopyFrom') to user = 'UserIwantToCopyTO'
I am sure that my example is rubbish but I tried to explain what I want to do.
So is there a chance to do that within sql-code? I have to build a template of a user schema with hundreds of tables, triggers, etc and copy it to several other user schemas.
Thanks for your advice!
JanThere are numerous examples available.
What you typically will want to do is:
For the export use the job_mode => 'SCHEMA' option
Export example
http://www.oracle-base.com/articles/10g/OracleDataPump10g.php
DECLARE
l_dp_handle NUMBER;
l_last_job_state VARCHAR2(30) := 'UNDEFINED';
l_job_state VARCHAR2(30) := 'UNDEFINED';
l_sts KU$_STATUS;
BEGIN
l_dp_handle := DBMS_DATAPUMP.open(
operation => 'EXPORT',
job_mode => 'SCHEMA',
remote_link => NULL,
job_name => 'EMP_EXPORT',
version => 'LATEST');
DBMS_DATAPUMP.add_file(
handle => l_dp_handle,
filename => 'SCOTT.dmp',
directory => 'TEST_DIR');
DBMS_DATAPUMP.add_file(
handle => l_dp_handle,
filename => 'SCOTT.log',
directory => 'TEST_DIR',
filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
DBMS_DATAPUMP.metadata_filter(
handle => l_dp_handle,
name => 'SCHEMA_EXPR',
value => '= ''SCOTT''');
DBMS_DATAPUMP.start_job(l_dp_handle);
DBMS_DATAPUMP.detach(l_dp_handle);
END;
/for the import you will have to use the remap_schema option with:
DBMS_DATAPUMP.METADATA_REMAP (
handle IN NUMBER,
name IN VARCHAR2,
old_value IN VARCHAR2,
value IN VARCHAR2,
object_type IN VARCHAR2 DEFAULT NULL);There are much more details in the document that Thierry provided. -
Create error and integration tables o source
Hi,
I would like to perform all the integration steps on the source schema and then just put the data on my target table. This means that I want to create I$ and E$ tables on the source schema. How can I handle this? Shall I write a new CKM? I'm working with Oracle as source and target databases...
Thanks!
R.Mistake from me, I do not think this is entirely possible.
Using CKMs and most of the incremental update IKMs suppose that objects are created on the target (Error tables are always created on the target server).
The configuration that would work is with no control and an "IKM SQL to SQL Append" used from the source to the target.
Regards,
-FX
PS: Sorry, I had no coffee (yet) ;-) -
Moving Subpartitions to a duplicate table in a different schema.
+NOTE: I asked this question on the PL/SQL and SQL forum, but have moved it here as I think it's more appropriate to this forum. I've placed a pointer to this post on the original post.+
Hello Ladies and Gentlemen.
We're currently involved in an exercise at my workplace where we are in the process of attempting to logically organise our data by global region. For information, our production database is currently at version 10.2.0.3 and will shortly be upgraded to 10.2.0.5.
At the moment, all our data 'lives' in the same schema. We are in the process of producing a proof of concept to migrate this data to identically structured (and named) tables in separate database schemas; each schema to represent a global region.
In our current schema, our data is range-partitioned on date, and then list-partitioned on a column named OFFICE. I want to move the OFFICE subpartitions from one schema into an identically named and structured table in a new schema. The tablespace will remain the same for both identically-named tables across both schemas.
Do any of you have an opinion on the best way to do this? Ideally in the new schema, I'd like to create each new table as an empty table with the appropriate range and list partitions defined. I have been doing some testing in our development environment with the EXCHANGE PARTITION statement, but this requires the destination table to be non-partitioned.
I just wondered if, for partition migration across schemas with the table name and tablespace remaining constant, there is an official "best practice" method of accomplishing such a subpartition move neatly, quickly and elegantly?
Any helpful replies welcome.
Cheers.
JamesYou CAN exchange a subpartition into another table using a "temporary" (staging) table as an intermediary.
See :
SQL> drop table part_subpart purge;
Table dropped.
SQL> drop table NEW_part_subpart purge;
Table dropped.
SQL> drop table STG_part_subpart purge;
Table dropped.
SQL>
SQL> create table part_subpart(col_1 number not null, col_2 varchar2(30))
2 partition by range (col_1) subpartition by list (col_2)
3 (
4 partition p_1 values less than (10) (subpartition p_1_s_1 values ('A'), subpartition p_1_s_2 values ('B'), subpartition p_1_s_3 values ('C'))
5 ,
6 partition p_2 values less than (20) (subpartition p_2_s_1 values ('A'), subpartition p_2_s_2 values ('B'), subpartition p_2_s_3 values ('C'))
7 )
8 /
Table created.
SQL>
SQL> create index part_subpart_ndx on part_subpart(col_1) local;
Index created.
SQL>
SQL>
SQL> insert into part_subpart values (1,'A');
1 row created.
SQL> insert into part_subpart values (2,'A');
1 row created.
SQL> insert into part_subpart values (2,'B');
1 row created.
SQL> insert into part_subpart values (2,'B');
1 row created.
SQL> insert into part_subpart values (2,'C');
1 row created.
SQL> insert into part_subpart values (11,'A');
1 row created.
SQL> insert into part_subpart values (11,'C');
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> create table NEW_part_subpart(col_1 number not null, col_2 varchar2(30))
2 partition by range (col_1) subpartition by list (col_2)
3 (
4 partition n_p_1 values less than (10) (subpartition n_p_1_s_1 values ('A'), subpartition n_p_1_s_2 values ('B'), subpartition n_p_1_s_3 values ('C'))
5 ,
6 partition n_p_2 values less than (20) (subpartition n_p_2_s_1 values ('A'), subpartition n_p_2_s_2 values ('B'), subpartition n_p_2_s_3 values ('C'))
7 )
8 /
Table created.
SQL>
SQL> create table STG_part_subpart(col_1 number not null, col_2 varchar2(30))
2 /
Table created.
SQL>
SQL> -- ensure that the Staging table is empty
SQL> truncate table STG_part_subpart;
Table truncated.
SQL> -- exchanging a subpart out of part_subpart
SQL> alter table part_subpart exchange subpartition
2 p_2_s_1 with table STG_part_subpart;
Table altered.
SQL> -- exchanging the subpart into NEW_part_subpart
SQL> alter table NEW_part_subpart exchange subpartition
2 n_p_2_s_1 with table STG_part_subpart;
Table altered.
SQL>
SQL>
SQL> select * from NEW_part_subpart subpartition (n_p_2_s_1);
COL_1 COL_2
11 A
SQL>
SQL> select * from part_subpart subpartition (p_2_s_1);
no rows selected
SQL>I have exchanged subpartition p_2_s_1 out of the table part_subpart into the table NEW_part_subpart -- even with a different name for the subpartition (n_p_2_s_1) if so desired.
NOTE : Since your source and target tables are in different schemas, you will have to move (or copy) the staging table STG_part_subpart from the first schema to the second schema after the first "exchange subpartition" is done. You will have to do this for every subpartition to be exchanged.
Hemant K Chitale
Edited by: Hemant K Chitale on Apr 4, 2011 10:19 AM
Added clarification for cross-schema exchange. -
I would like to include interactive tables that would recalculate using formulas I have written and values that the reader/user has entered into selected cells. The tables I've made in iBooks Author do contain formulas that work as expected...until exported to an iPad, then they look and act just like a static table. I am not looking for serious number crunching or high-end mathematics, although others might find great value in such capability.
To work without a reader/user accidentally (or otherwise) altering formulas or formatting it would be necessary to lock some or most cells of the table. At present all cells are locked after export. Apple doesn't seem to envision or value the functionality of such a feature; it appears to me missing from Numbers as well.Should be near trivial to execute on with an app...
As welll, I wouldn't be surprised if a dashcode widget would fit the bill.
As always, feel free to use the 'Provide iBooks Author Feedback' menu item for features you'd like added in the future, etc.
http://www.apple.com/feedback/ibooks-author.html -
Write the DDL to construct the Facebook User and Post tables in SQL server.
Write the DDL to construct the Facebook User and Post tables in SQL server. You need to populate the user table with the user’s information provided as in Figure 1 and additional attributes may be needed for the design. Use the ID in the excel file to
identify the other Facebook user. For example ID 612831408762037 is David Cunliffe. Import the excel sheets to SQL server and then write effective SQL to merge the two tables into the Post table. Ensure the relationship is maintained between entities. Submit
the SQL scripts that create the database and tables, import the excel sheets and populate the tables such that one can re-create the database and tables with all the data by running the script.IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = N'xxx')
CREATE DATABASE xxx
GO
USE xxx
IF EXISTS(SELECT * FROM sys.tables WHERE name = N'DAVID')
DROP TABLE DAVID;
IF EXISTS(SELECT * FROM sys.tables WHERE name = N'JOHN')
DROP TABLE JOHN;
IF EXISTS(SELECT * FROM sys.tables WHERE name = N'NEWDAVID')
DROP TABLE NEWDAVID;
IF EXISTS(SELECT * FROM sys.tables WHERE name = N'NEWJOHN')
DROP TABLE NEWJOHN;
IF EXISTS(SELECT * FROM sys.tables WHERE name = N'USER')
DROP TABLE [USER];
IF EXISTS(SELECT * FROM sys.tables WHERE name = N'POST')
DROP TABLE POST;
CREATE TABLE DAVID(
ID VARCHAR(100),
[MESSAGE] VARCHAR(MAX),
[TYPE] VARCHAR(MAX),
CREATED_TIME VARCHAR(MAX),
UPDATED_TIME VARCHAR(MAX),
SHARES_COUNT VARCHAR(MAX),
[COUNT OF LIKES NAME] VARCHAR(MAX),
[COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
LINK VARCHAR(MAX),
NAME VARCHAR(MAX),
[DESCRIPTION] VARCHAR(MAX),
CREATE TABLE JOHN(
ID VARCHAR(100),
LINK VARCHAR(MAX),
NAME VARCHAR(MAX),
[DESCRIPTION] VARCHAR(MAX),
[TYPE] VARCHAR(MAX),
CREATED_TIME VARCHAR(MAX),
UPDATED_TIME VARCHAR(MAX),
[COUNT OF LIKES NAME] VARCHAR(MAX),
[COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
[MESSAGE] VARCHAR(MAX),
SHARES_COUNT VARCHAR(MAX),
EXECUTE (N'BULK INSERT DAVID FROM ''' + 'datapath' + N'david.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE = ''char'',
FIELDTERMINATOR= '','',
ROWTERMINATOR = ''\n'',
KEEPIDENTITY,
TABLOCK
EXECUTE (N'BULK INSERT JOHN FROM ''' + 'datapath' + N'john.csv''
WITH (
CHECK_CONSTRAINTS,
CODEPAGE=''ACP'',
DATAFILETYPE = ''char'',
FIELDTERMINATOR= '','',
ROWTERMINATOR = ''\n'',
KEEPIDENTITY,
TABLOCK
SELECT * FROM DAVID
SELECT * FROM JOHN
CREATE TABLE NEWDAVID(
POST_ID VARCHAR(100),
[USER_ID] VARCHAR(100),
CREATED_DATE VARCHAR(MAX),
CREATED_YEAR VARCHAR(MAX),
CREATED_MONTH VARCHAR(MAX),
UPDATED_DATE VARCHAR(MAX),
UPDATED_YAER VARCHAR(MAX),
UPDATED_MONTH VARCHAR(MAX),
[MESSAGE] VARCHAR(MAX),
SHARES_COUNT VARCHAR(MAX),
[COUNT OF LIKES NAME] VARCHAR(MAX),
[COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
NAME VARCHAR(MAX),
[TYPE] VARCHAR(MAX),
LINK VARCHAR(MAX),
[DESCRIPTION] VARCHAR(MAX),
CREATE TABLE NEWJOHN(
POST_ID VARCHAR(100),
[USER_ID] VARCHAR(100),
CREATED_DATE VARCHAR(MAX),
CREATED_YEAR VARCHAR(MAX),
CREATED_MONTH VARCHAR(MAX),
UPDATED_DATE VARCHAR(MAX),
UPDATED_YAER VARCHAR(MAX),
UPDATED_MONTH VARCHAR(MAX),
[MESSAGE] VARCHAR(MAX),
SHARES_COUNT VARCHAR(MAX),
[COUNT OF LIKES NAME] VARCHAR(MAX),
[COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
NAME VARCHAR(MAX),
[TYPE] VARCHAR(MAX),
LINK VARCHAR(MAX),
[DESCRIPTION] VARCHAR(MAX),
INSERT INTO NEWJOHN
SELECT SUBSTRING(ID, CHARINDEX('_', ID) + 1, LEN(ID) - CHARINDEX('_', ID)) AS POST_ID,
SUBSTRING(ID, 1, CHARINDEX('_', ID) -1) AS [USER_ID],
SUBSTRING(CREATED_TIME, 1, 10) AS CREATED_DATE,
SUBSTRING(CREATED_TIME, 1, 4) AS CREATED_YEAR,
SUBSTRING(CREATED_TIME, 6, 2) AS CREATED_MONTH,
SUBSTRING(UPDATED_TIME, 1, 10) AS UPDATED_DATE,
SUBSTRING(UPDATED_TIME, 1, 4) AS UPDATED_YEAR,
SUBSTRING(UPDATED_TIME, 6, 2) AS UPDATED_MONTH,
[MESSAGE], SHARES_COUNT, [COUNT OF LIKES NAME], [COUNT OF COMMENTS MESSAGE], NAME, [TYPE], LINK, [DESCRIPTION]
FROM JOHN
INSERT INTO NEWDAVID
SELECT SUBSTRING(ID, CHARINDEX('_', ID) + 1, LEN(ID) - CHARINDEX('_', ID)) AS POST_ID,
SUBSTRING(ID, 1, CHARINDEX('_', ID) -1) AS [USER_ID],
SUBSTRING(CREATED_TIME, 1, 10) AS CREATED_DATE,
SUBSTRING(CREATED_TIME, 1, 4) AS CREATED_YEAR,
SUBSTRING(CREATED_TIME, 6, 2) AS CREATED_MONTH,
SUBSTRING(UPDATED_TIME, 1, 10) AS UPDATED_DATE,
SUBSTRING(UPDATED_TIME, 1, 4) AS UPDATED_YEAR,
SUBSTRING(UPDATED_TIME, 6, 2) AS UPDATED_MONTH,
[MESSAGE], SHARES_COUNT, [COUNT OF LIKES NAME], [COUNT OF COMMENTS MESSAGE], NAME, [TYPE], LINK, [DESCRIPTION]
FROM DAVID
SELECT * FROM NEWDAVID
SELECT * FROM NEWJOHN
CREATE TABLE POST (
POST_ID VARCHAR(100) NOT NULL,
[USER_ID] VARCHAR(100),
CREATED_DATE VARCHAR(MAX),
CREATED_YEAR VARCHAR(MAX),
CREATED_MONTH VARCHAR(MAX),
UPDATED_DATE VARCHAR(MAX),
UPDATED_YAER VARCHAR(MAX),
UPDATED_MONTH VARCHAR(MAX),
[MESSAGE] VARCHAR(MAX),
SHARES_COUNT VARCHAR(MAX),
[COUNT OF LIKES NAME] VARCHAR(MAX),
[COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
NAME VARCHAR(MAX),
[TYPE] VARCHAR(MAX),
LINK VARCHAR(MAX),
[DESCRIPTION] VARCHAR(MAX),
INSERT INTO POST
SELECT * FROM NEWDAVID UNION SELECT * FROM NEWJOHN
SELECT * FROM POST
CREATE TABLE [USER]
[USER_ID] VARCHAR(100) NOT NULL,
INSERT INTO [USER] VALUES (612831408762037),(1119736203)
ALTER TABLE [USER] ADD PRIMARY KEY([USER_ID])
ALTER TABLE POST ADD PRIMARY KEY(POST_ID)
ALTER TABLE POST ADD FOREIGN KEY([USER_ID]) REFERENCES [USER]([USER_ID]) -
Attach User define tables and view table need add to database into my add-o
Hi there,
I want to deploy an addon, there are User define tables and view table need add to database.
I need some advice on some issues..
1. Can I attach User define tables and view table need add to database into my addon.
2. I wonder which chance is properly to add them, if add these user define objects in time of install and I can't get the enough information that connect to SQL server
Thanks for any help.Hi Weerachai,
Here's an example of how to create a user-defined table in code. My suggestion would be to check if it exists when your add-on starts up and then if not, create the tables, fields and objects.
'User Table
Private Sub CreateTable(ByVal sTable As String, ByVal sDescription As String, ByVal oObjectType As SAPbobsCOM.BoUTBTableType)
Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
Dim iResult As Long
Dim sMsg As String
oUserTablesMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
If Not oUserTablesMD.GetByKey(sTable) Then
oUserTablesMD.TableName = sTable
oUserTablesMD.TableDescription = sDescription
oUserTablesMD.TableType = oObjectType
iResult = oUserTablesMD.Add()
If iResult <> 0 Then
oCompany.GetLastError(iResult, sMsg)
MessageBox.Show("Error Creating Table: " & sTable & " Error: " & sMsg)
End If
End If
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTablesMD)
End Sub
'User Field
Private Sub CreateField(ByVal sTable As String, ByVal sName As String, ByVal sDescription As String, _
ByVal iSize As Integer, ByVal aFieldType As SAPbobsCOM.BoFieldTypes, _
ByVal aSubType As SAPbobsCOM.BoFldSubTypes, ByVal sLink As String, _
ByVal bMandatory As SAPbobsCOM.BoYesNoEnum)
Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
Dim oTable As SAPbobsCOM.UserTable
Dim iResult As Long
Dim sMsg As String
Dim i As Integer
Dim x As Integer
Dim bFound As Boolean = False
Dim oField As SAPbobsCOM.Field
oTable = oCompany.UserTables.Item(sTable)
For i = 0 To oTable.UserFields.Fields.Count - 1
oField = oTable.UserFields.Fields.Item(i)
'MessageBox.Show(oField.Name)
If oField.Name = "U_" & sName Then
bFound = True
End If
Next
System.Runtime.InteropServices.Marshal.ReleaseComObject(oTable)
If Not bFound Then
oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
oUserFieldsMD.TableName = "@" & sTable
oUserFieldsMD.Name = sName
oUserFieldsMD.Description = sDescription
oUserFieldsMD.Type = aFieldType
If aFieldType = SAPbobsCOM.BoFieldTypes.db_Alpha Or aFieldType = SAPbobsCOM.BoFieldTypes.db_Numeric Then
oUserFieldsMD.EditSize = iSize
Else
oUserFieldsMD.SubType = aSubType
oUserFieldsMD.Mandatory = bMandatory
End If
oUserFieldsMD.LinkedTable = sLink
iResult = oUserFieldsMD.Add()
If iResult <> 0 Then
oCompany.GetLastError(iResult, sMsg)
MessageBox.Show("Error Creating Field: " & sTable & "." & sName & " Error: " & sMsg)
End If
System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD)
End If
End Sub
If you want to create a View I think you would have to use the RecordSet object. This will ensure that you don't have to log in to the database again
Hope it helps,
Adele -
How to read and write data to a user defined table?
I have created a srf with 2 edit box and a ok buttin, I want to insert data to the user defined table i created using sql query while i press OK button..
Please provide the complete code to insert and select da from the user defined table.Hi,
You can use the code below.
Dim ret As Long
d
Private Sub Add_Table_Click()
Dim oUserTablesMD As SAPbobsCOM.UserTablesMD
Set oUserTablesMD = oCompany.GetBusinessObject(oUserTables)
' When adding user tables or fields, use a prefix
' identifying your partner name space. This will
' prevent collisions from different partner add-ons
' SAP's name space prefix is "BE_"
'Set the two mandatory fields
oUserTablesMD.TableName = "T1"
oUserTablesMD.TableDescription = "Table1"
'Add the table (which contains 2 default, mandatory fields, 'Code' and 'Name')
ret = oUserTablesMD.Add
If ret <> 0 Then
oCompany.GetLastError ret, Str
MsgBox Str
Else
MsgBox "Table: " & oUserTablesMD.TableName & " was added successfully"
End If
End Sub
Private Sub Add_UDF_Click()
Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
Set oUserFieldsMD = oCompany.GetBusinessObject(oUserFields)
oUserFieldsMD.TableName = "T1"
oUserFieldsMD.Name = "AlbUDF"
oUserFieldsMD.Description = "Albert UDF"
'Add the field to the table
lRetCode = oUserFieldsMD.Add
If lRetCode <> 0 Then
oCompany.GetLastError ret, Str
MsgBox Str
Else
MsgBox "Field: '" & oUserFieldsMD.Name & "' was added successfuly to " & oUserFieldsMD.TableName & " Table"
End If
End Sub
Private Sub Add_Data_Click()
Dim oUserTable As SAPbobsCOM.UserTable
Set oUserTable = oCompany.UserTables.Item(1)
oUserTable.GetByKey ("T1")
'Set default, mandatory fields
oUserTable.Code = "A"
oUserTable.Name = "Albert"
'Set user field
oUserTable.UserFields.Fields.Item("U_AlbUDF").Value = "1"
oUserTable.Add
If ret <> 0 Then
oCompany.GetLastError ret, Str
MsgBox Str
Else
MsgBox "Value to field: '" & oUserTable.UserFields.Fields.Item("U_AlbUDF").Name & "' was updated successfuly to " & oUserTable.TableName & " Table"
End If
End Sub
Regards,
Noor
Maybe you are looking for
-
I have read through all of the responses to this exact questions posed by other users and nothing is working. What is the most frustrating is that this is not a constant issue. One minute I will be logged onto Facebook and when I try to visit a frien
-
I logged on to Foxfire, Google then did a search for a pattern for a Belly Dancers hip scarf with bangles. After checking out a few sites, a Security Alert appears on my screen with the FOXFIRE logo and a list of Virus/Trojan with critical and high r
-
SAP Script - Logical expression in multi lines
Hi Friends, How can I write logical expression in more than one lines in SAP script editor? Case: I have to write: IF &J_1BPRNFHD-DIRECT& = '1' AND &J_1BPRNFHD-MANUAL& = 'X' AND &J_1BPRNFHD-SHPUNT& = ' ' I am writing in first line /: IF &J_1BPRNFHD-
-
Upgrading Weblogic 8.1, SP2 to Weblogic 8.1, SP6
wanna to the code changes that are required in web application while upgrading Weblogic 8.1, SP2 to Weblogic 8.1, SP6.
-
Hi, my 2nd generation iPod Touch screen won't work properly (which I got a year ago along with a university special with a Macbook Pro). When I plug it to iTunes, it shows all the info thats in the iPod, but the screen would only turn bright-white fo