ddl

MySQL terminology “constraints” vs “foreign keys” difference?

ぃ、小莉子 提交于 2019-12-17 21:44:39
问题 I'm looking at the MySQL docs here and trying to sort out the distinction between FOREIGN KEYs and CONSTRAINTs. I thought an FK was a constraint, but the docs seem to talk about them like they're separate things. The syntax for creating an FK is (in part)... [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name, ...) REFERENCES tbl_name (index_col_name,...) So the "CONSTRAINT" clause is optional. Why would you include it or not include it? If you leave it out does MySQL create a

Give all the permissions to a user on a DB

ぃ、小莉子 提交于 2019-12-17 21:24:40
问题 I would like to give an user all the permissions on a database without making it an admin. The reason why I want to do that is that at the moment DEV and PROD are different DBs on the same cluster so I don't want a user to be able to change production objects but it must be able to change objects on DEV. I tried: grant ALL on database MY_DB to group MY_GROUP; but it doesn't seem to give any permission. Then I tried: grant all privileges on schema MY_SCHEMA to group MY_GROUP; and it seems to

JPA - How to set string column to varchar(max) in DDL

十年热恋 提交于 2019-12-17 18:45:43
问题 With JPA, DDL-generation for the attribute: @Column final String someString; will be someString varchar(255) null @Column(length = 1337) final String someString; will yield someString varchar(1337) null . But how can I get it to produce someString varchar(max) null ? Is it possible using the length -attribute, or do I need to use the columnDefinition -attribute? 回答1: Some months have passed, new knowledge acquired, so I'll answer my own question: @Lob @Column final String someString; yields

Do DDL statements always give you an implicit commit, or can you get an implicit rollback?

白昼怎懂夜的黑 提交于 2019-12-17 15:56:13
问题 If you're halfway through a transaction and perform a DDL statement, such as truncating a table, then the transaction commits. I was wondering whether this was always the case and by definition, or is there a setting hidden somewhere that would rollback the transaction instead of committing. Thanks. Edit to clarify... I'm not looking to rollback after a truncate. I just want to confirm that statements already carried out are absolutely always going to be committed before a DDL. Just want to

ALTER TABLE without locking the table?

落爺英雄遲暮 提交于 2019-12-17 08:04:16
问题 When doing an ALTER TABLE statement in MySQL, the whole table is read-locked for the duration of the statement. If it's a big table, that means insert or update statements could be locked for a looooong time. Is there a way to do a "hot alter", like adding a column in such a way that the table is still updatable throughout the process? Mostly I'm interested in a solution for MySQL but I'd be interested in other RDBMS if MySQL can't do it. To clarify, my purpose is simply to avoid downtime

ALTER TABLE without locking the table?

南笙酒味 提交于 2019-12-17 08:04:05
问题 When doing an ALTER TABLE statement in MySQL, the whole table is read-locked for the duration of the statement. If it's a big table, that means insert or update statements could be locked for a looooong time. Is there a way to do a "hot alter", like adding a column in such a way that the table is still updatable throughout the process? Mostly I'm interested in a solution for MySQL but I'd be interested in other RDBMS if MySQL can't do it. To clarify, my purpose is simply to avoid downtime

ALTER TABLE without locking the table?

别说谁变了你拦得住时间么 提交于 2019-12-17 08:04:03
问题 When doing an ALTER TABLE statement in MySQL, the whole table is read-locked for the duration of the statement. If it's a big table, that means insert or update statements could be locked for a looooong time. Is there a way to do a "hot alter", like adding a column in such a way that the table is still updatable throughout the process? Mostly I'm interested in a solution for MySQL but I'd be interested in other RDBMS if MySQL can't do it. To clarify, my purpose is simply to avoid downtime

How do I add a foreign key to an existing SQLite table?

前提是你 提交于 2019-12-17 07:07:41
问题 I have the following table: CREATE TABLE child( id INTEGER PRIMARY KEY, parent_id INTEGER, description TEXT); How do I add a foreign key constraint on parent_id ? Assume foreign keys are enabled. Most examples assume you're creating the table - I'd like to add the constraint to an existing one. 回答1: You can't. Although the SQL-92 syntax to add a foreign key to your table would be as follows: ALTER TABLE child ADD CONSTRAINT fk_child_parent FOREIGN KEY (parent_id) REFERENCES parent(id); SQLite

Oracle: DDL and transaction rollback

血红的双手。 提交于 2019-12-17 06:49:05
问题 Could in Oracle DDL (create/alter) be transactional like they are in MS SQL (started from 2005)? 回答1: No. In Oracle DDL statements themselves are not transactional. Running a DDL statement will implicitly commit any open transaction for that session before starting the actual work. In addition some statements, like an alter table statement, may fail if another session has an open transaction on the object being modified or one of its dependencies. You can set a ddl_lock_timeout to specify how

How to get function parameter lists (so I can drop a function)

随声附和 提交于 2019-12-17 06:13:43
问题 I want to get the SQL to drop a function in PostgreSQL. I write DROP FUNCTION and a get function name from pg_proc . That is not problem. However if I leave blank parameters it will not drop the function. I checked the manual and there is written then I have to identify the function with its parameters to drop it, eg DROP FUNCTION some_func(text,integer) not just DROP FUNCTION some_func . Where can I find the parameters? In the function's row on in the pg_proc table there is no parameters. So