primary-key

Finding the height of the B-Tree of a table in SQL Server

≯℡__Kan透↙ 提交于 2019-12-07 01:54:10
问题 Since database data is organized in 8k pages in a B-tree, and likewise for PK information information, it should be possible for each table in the database to calculate the height of the B-Tree. Thus revealing how many jumps it takes to reach certain data. Since both row size and PK size is of great importance, it is difficult to calculate since eg varchar(250) need not take up 250 bytes. 1) Is there a way to get the info out of SQL Server? 2) if not, is it possible to give a rough estimate

Oracle primary keys: NUMBER vs NUMBER(7,0)

大城市里の小女人 提交于 2019-12-07 01:13:53
问题 Is there any benefit to specifying the precision on the PK? Is 7,0 sufficient, given that there will probably never be more than a few thousand records? Any dangers to not specifying the precision? 回答1: NUMBER(7, 0) just constrains the domain of values. Their internal represenations do not differ: CREATE TABLE t_pk (col1 NUMBER(7, 0) NOT NULL, col2 NUMBER(38) NOT NULL) INSERT INTO t_pk VALUES (9999999, 9999999) SELECT DUMP(col1), DUMP(col2) FROM t_pk DUMP(col1) DUMP(col2) --- --- Typ=2 Len=5:

Turnoff mysql unsafe statement warning

独自空忆成欢 提交于 2019-12-07 00:35:55
问题 I am using log-error to write warning/errors into a file. When I perform INSERT IGNORE..SELECT statement, it just keep write this warning messages. 120905 3:01:23 [Warning] Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. INSERT IGNORE... SELECT is unsafe because the order in which rows are retrieved by the SELECT determines which (if any) rows are ignored. This order cannot be predicted and may differ on master and the slave. I want to stop

numeric(38,0) as primary key column; good, bad, who cares?

瘦欲@ 提交于 2019-12-06 19:37:45
问题 On my current project, I came across our master DB script. Taking a closer look at it, I noticed that all of our original primary keys have a data type of numeric(38,0) We are currently running SQL Server 2005 as our primary DB platform. For a little context, we support both Oracle and SQL Server as our back-end. In Oracle, our primary keys have a data type of number(38,0). Does anybody know of possible side-effects and performance impact of such implementation? I have always advocated and

Primary key and foreign key at the same time with doctrine 2

冷暖自知 提交于 2019-12-06 19:19:13
问题 I have the two tables : table A with id as primary key table B with id as primary key and foreign key Explanation on short: I need to have in table B a primary key that also to be a foreign key that points to table A 's primary key. Can anybody explain me how to map this by annotations in Doctrine 2? Note: I tried it By this : class A { /** * @var bigint $id * * @Column(name="id", type="bigint", nullable=false) * @Id * @GeneratedValue(strategy="IDENTITY") */ private $a_id; ... and B table:

Fluent NHibernate primary key constraint naming conventions

こ雲淡風輕ζ 提交于 2019-12-06 18:29:47
问题 Is there any way to create a naming convention for my primary key constraints in Fluent NHibernate? I know you can name foreign key constraints, but it does not appear possible to name the primary key constraint. 回答1: James Gregory from FNH says... No, that's not supported through NHibernate, so we can't support it either. http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/9ea7155407d33772 来源: https://stackoverflow.com/questions/1358043/fluent-nhibernate-primary-key

Primary key in cassandra is unique?

你。 提交于 2019-12-06 16:44:49
问题 It could be kind of lame but in cassandra has the primary key to be unique? For example in the following table: CREATE TABLE users ( name text, surname text, age int, adress text, PRIMARY KEY(name, surname) ); So if is it possible in my database to have 2 persons in my database with the same name and surname but different ages? Which means same primary key.. 回答1: Yes the primary key has to be unique. Otherwise there would be no way to know which row to return when you query with a duplicate

what's the performance difference between int and varchar for primary keys

ぃ、小莉子 提交于 2019-12-06 13:53:21
问题 I need to create a primary key scheme for a system that will need peer to peer replication. So I'm planning to combine a unique system ID and a sequential number in some way to come up with unique ID's. I want to make sure I'll never run out of ID's, so I'm thinking about using a varchar field, since I could always add another character if I start running out. But I've read that integers are better optimized for this. So I have some questions... 1) Are integers really better optimized? And if

How to add a Primary Key on a Oracle view? [duplicate]

强颜欢笑 提交于 2019-12-06 13:43:53
This question already has an answer here : Closed 7 years ago . Possible Duplicate: adding primary key to sql view I'm working with a software that requires a primary key in a Oracle view. There is possible to add a Primary key in a Oracle view? If yes, how? I can't google information about this. The SQL standard unfortunately only permits UNIQUE and PRIMARY KEY constraints on base tables, not views. Oracle permits unique indexes on materialized views but not on views generally. The only thing that comes in my mind is using a materialized view and then create a unique index on it: drop

Example of when you should use a foreign key that points to a candidate key, not a primary key?

我的梦境 提交于 2019-12-06 12:52:46
问题 From my reading, I understand what makes a good primary key, what a foreign key is and what a candidate key is. I've read in several different books and sources that: A foreign key must point to a candidate key (or primary) A foreign key almost always points to a primary key The authors of the sources always say something along the lines of, "while foreign keys can point at a candidate key (not primary) they seem to". Are there any examples of why you might choose a candidate key and not the