I am working with the WSO2 IS 5.2.0
for some reasons, I would like to change the data schema of the default embedded H2 database.
for example,
the maximum length of volume "ACCESS_TOKEN" in table "IDN_OAUTH2_ACCESS_TOKEN" is 255 chars. I would like to change it to 8194.
I made the following change the configuration file "/dbscripts/identity/h2.sql" (see the value "8194")
CREATE TABLE IF NOT EXISTS IDN_OAUTH2_ACCESS_TOKEN (
TOKEN_ID VARCHAR (255),
ACCESS_TOKEN VARCHAR (8194),
REFRESH_TOKEN VARCHAR (255),
CONSUMER_KEY_ID INTEGER,
AUTHZ_USER VARCHAR (100),
TENANT_ID INTEGER,
USER_DOMAIN VARCHAR(50),
USER_TYPE VARCHAR (25),
GRANT_TYPE VARCHAR (50),
TIME_CREATED TIMESTAMP DEFAULT 0,
REFRESH_TOKEN_TIME_CREATED TIMESTAMP DEFAULT 0,
VALIDITY_PERIOD BIGINT,
REFRESH_TOKEN_VALIDITY_PERIOD BIGINT,
TOKEN_SCOPE_HASH VARCHAR (32),
TOKEN_STATE VARCHAR (25) DEFAULT 'ACTIVE',
TOKEN_STATE_ID VARCHAR (128) DEFAULT 'NONE',
SUBJECT_IDENTIFIER VARCHAR(255),
PRIMARY KEY (TOKEN_ID),
FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE,
CONSTRAINT CON_APP_KEY UNIQUE (CONSUMER_KEY_ID,AUTHZ_USER,TENANT_ID,USER_DOMAIN,USER_TYPE,TOKEN_SCOPE_HASH,
TOKEN_STATE,TOKEN_STATE_ID)
the problems is that I just cannot put this change into effect. I did everything (restart, reinstall), the original settings ("256") persists...
it seems that the database schema had been generated in the IS server image. and the generating script file says "GENERATE IF NOT EXISTS..."
anyone has any idea?
thanks
Remove <IS_HOME>/repository/database/*. Then start server with -Dsetup.
./wso2server.sh -Dsetup
Yes, It is generated with the server distribution. What you can do is (backup and) remove the content of repository/database, update the db scripts and start the server with bin/wso2server.sh -Dsetup. This needs to be done only once, from next time on you can start the server as usual.
One other possibility is to use the H2 console. If you already have data, it will be the better option.
Related
The opencart 3.0.2.0 system will limit users from entering their address in checkout more than 128 characters, is there any possible ways to modify this?
I do have some customers complain to me about this.
You can change it with this query:
ALTER TABLE `oc_address` CHANGE `address_1` `address_1` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
Note: if your database prefix is not oc_, edit above query and use your actual database prefix.
This query will change the address_1 limit from 128 to 256.
Problem.
After successful data migration from csv files to django /Postgres application .
When I try to add a new record via the application interface getting - duplicate key value violates unique constraint.(Since i had id's in my csv files -i use them as keys )
Basically the app try to generate id's that already migrated.
After each attempt ID increments by one so if I have 160 record I have to get this error 160 times and then when I try 160 times the time 161 record saves ok.
Any ideas how to solve it?
PostgreSQL doesn't have an actual AUTO_INCREMENT column, at least not in the way that MySQL does. Instead it has a special SERIAL. This creates a four-byte INT column and attaches a trigger to it. Behind the scenes, if PostgreSQL sees that there is no value in that ID column, it checks the value of a sequence created when that column was created.
You can see this by:
SELECT
TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME='<your-table>' AND COLUMN_NAME = '<your-id-column>';
You should see something like:
table_name | column_name | column_default
--------------+---------------------------+-------------------------------------
<your-table> | <your-id-column> | nextval('<table-name>_<your-id-column>_seq'::regclass)
(1 row)
To resolve your particular issue, you're going to need to reset the value of the sequence (named <table-name>_<your-id-column>_seq) to reflect the current index.
ALTER SEQUENCE your_name_your_id_column_seq RESTART WITH 161;
Credit where credit is due.
Sequence syntax is here.
Finding the name is here.
I am trying to drop a foreign key in DB2 through the command line. I have succeeded in this many times and I am sure that I am using the correct syntax:
db2 "alter table TABLENAME drop constraint fk_keyname"
Output:
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "FK_KEYNAME" is an undefined name. SQLSTATE=42704
All my foreign keys are created with an uppercase name. Except for the key I now want to drop. I don't know how to got created with a lowercase name but it seems that it will not drop keys that are lowercase.
When I try to add this foreign key (while it still exists) I get the following message:
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0601N The name of the object to be created is identical to the existing
name "fk_keyname" of type "FOREIGN KEY". SQLSTATE=42710
Does anyone know how to drop foreign keys that have a lowercase name?
The answer by mustaccio worked. Tried all kinds of quotes but this way did the trick:
db2 'alter table TABLENAME drop constraint "fk_keyname"'
DB2 will convert object names to uppercase, unless they are quoted. Generally it's not a very good idea to create objects with lower- or mixed-case names. If your foreign key is actually "fk_keyname" (all lowercase), run db2 "alter table TABLENAME drop constraint \"fk_keyname\"" or db2 'alter table TABLENAME drop constraint "fk_keyname"'
This behaviour is not unique to DB2, by the way.
I've been trying to add a foreign key to my table using heidisql and I keep getting the error 1452.
After reading around I made sure all my tables were running on InnoDB as well as checking that they had the same datatype and the only way I can add my key is if I drop all my data which I don't intend to do since I have spent quite a few hours on this.
here is my table create code:
CREATE TABLE `data` (
`ID` INT(10) NOT NULL AUTO_INCREMENT,
#bunch of random other columns stripped out
`Ability_1` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
#more stripped tables
`Extra_Info` SET('1','2','3','Final','Legendary') NOT NULL DEFAULT '1' COLLATE 'utf8_unicode_ci',
PRIMARY KEY (`ID`),
UNIQUE INDEX `ID` (`ID`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
AUTO_INCREMENT=650;
here is table 2
CREATE TABLE `ability` (
`ability_ID` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
#stripped columns
`Name_English` VARCHAR(12) NOT NULL COLLATE 'utf8_unicode_ci',
PRIMARY KEY (`ability_ID`),
UNIQUE INDEX `ability_ID` (`ability_ID`)
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
AUTO_INCREMENT=165;
Finally here is the create code along with the error.
ALTER TABLE `data`
ADD CONSTRAINT `Ability_1` FOREIGN KEY (`Ability_1`) REFERENCES `ability` (`ability_ID`) ON UPDATE CASCADE ON DELETE CASCADE;
/* SQL Error (1452): Cannot add or update a child row: a foreign key constraint fails (`check`.`#sql-ec0_2`, CONSTRAINT `Ability_1` FOREIGN KEY (`Ability_1`) REFERENCES `ability` (`ability_ID`) ON DELETE CASCADE ON UPDATE CASCADE) */
If there is anything else I can provide please let me know this is really bothering me. I'm also using 5.5.27 - MySQL Community Server (GPL) that came with xampp installer.
If you are using HeidiSQL it is pretty easy.
Just see the image, click on the +Add to add foreign keys.
I prefer GUI way of creating tables and its attribute because it saves time and reduces errors.
I found it. Sorry everyone. The problem was that I had 0 as a default value for my fields while my original table had no value for 0.
Here is how you can do it ;
Create your Primary keys. For me this was straight forward so I won't post how to do that here
To create your FOREIGN KEYS you need to change the table / engine type for each table from MyIASM to InnoDb. To do this Select the table on the right hand side then select the OPTIONS tab on the right hand side and change the engine from MyIASM to InnoDb for every table.
I use Joomla and I recently installed a new Template.
To make the demo-content of said Template work, I need to import a .sql file into my database using phpMyAdmin.
However, after trying to import the file I get this error message:
SQL-Befehl [SQL-Order]:
--
-- Datenbank *[database]*: `j17_jp_investment`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur *[table structure]* für Tabelle *[table, sheet]* `jos_assets`
--
DROP TABLE IF EXISTS `jos_assets` ;
MySQL meldet [reports]: Dokumentation [documentation]
#1046 - No database selected
i had the same issue with a template i just bought!
Add the MySQL sentense: USE jml_d52ka2dc1f; where jml_d52ka2dc1f; is your database name.
Your dump.sql file should looks like this:
USE jml_d52ka2dc1f;
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
DROP TABLE IF EXISTS `jml_assets`;
CREATE TABLE IF NOT EXISTS `jml_assets` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`parent_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set parent.',
`lft` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set lft.',
`rgt` int(11) NOT NULL DEFAULT '0' COMMENT 'Nested set rgt.',
`level` int(10) unsigned NOT NULL COMMENT 'The cached level in the nested tree.',
`name` varchar(50) NOT NULL COMMENT 'The unique name for the asset.\n',
`title` varchar(100) NOT NULL COMMENT 'The descriptive title for the asset.',
`rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.',
PRIMARY KEY (`id`),
UNIQUE KEY `idx_asset_name` (`name`),
KEY `idx_lft_rgt` (`lft`,`rgt`),
KEY `idx_parent_id` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
:) Enjoy!
Reference: http://dev.mysql.com/doc/refman/5.0/en/use.html
Do you have a database called "j17_jp_investment"?
Otherwise remove that line from the .sql file, go to phpmyadmin, choose the database that joomla is using then go to the import tab and try importing.
The same error was showing up for me. I was trying to import my client's mySQL database to my WAMP server.
I just added these two words at the beginning of my SQL queries:
USE [database_name]
However, before doing so, I made sure that I created a database with the exact same name that I'm using in the code above.