SQL. , .
1) SQL, ISO/IEC/ANSI Standard SQL. - (while , , ). ; GROUP BY .. , , ( ). , , , .
2) , .. ; ( / ). . , ( ) .
, ; , , "" . ( SQL) , ( ). Eek, SQL. .
SQL, (HSQL - ), . SQL, , , .
(, "psuedo-SQL".)
ID
, , , - , . , . .
CREATE TABLE Person (
PersonId IDENTITY NOT NULL
PRIMARY KEY,
FirstName CHAR(30) NOT NULL,
LastName CHAR(30) NOT NULL
)
INSERT Person VALUES ("Fred", "Astaire")
1 row(s) affected
INSERT Person VALUES ("Ginger", "Rogers")
1 row(s) affected
INSERT Person VALUES ("Fred", "Astaire")
1 row(s) affected
SELECT * FROM Person
PersonId FirstName LastName
======== ============================== ==============================
1 Fred Astaire
2 Ginger Rogers
3 Fred Astaire
3 row(s) affected
That a pure, unarguable duplicate row. The simple fact is. the
ID column provides a row number, but does nothing to prevent duplicate rows. For that you need an
Unique Index on the columns that determine uniqueness, as identified in the data model, for every relational table in the database (by definition, if the rows are not unique, it is not a Relational table). Otherwise it is just a file storage system.
CREATE UNIQUE NONCLUSTERED INDEX U_Name
ON Person (LastName, FirstName)
There is another form of data integrity (duplication) which I might identify while I am at it.
INSERT Person VALUES ("Fred", "Astair")
1 row(s) affected
INSERT Person VALUES ("Astaire", "Fred")
1 row(s) affected
All are preventable in SQL.