を考えると、次のスキーマ:SQL増分値1
私はterm
の記録やテーブル
term_documento
で
document
を持っていない場合は、文書
path
用語
description
考える
document(id, path);
term(id, description);
term_document(id_term,id_document,frequency);
私は周波数= 1のテーブルterm_document
に挿入したいのですが、それ以外の場合は、frequency
の値を増やしたいだけです。私がこれまでやってき何
はこれです:
insert into term_document(id_term, id_document, frequency)
select term.id, document.id, 1
from term, document where term.description='to' and document.path='/home/rogger/Projetos/projeto-ori-ufu/src/main/resources/d1.txt'
私はterm_documentのレコードを持っていけない場合をsatistiesが、私は両方を満たすためにインクリメントする方法がわからないもの。
これは、idごとのシーケンスの再作成のトピックです。並行書き込みアクセス権を持っている場合、最善の答えは、そうではありません。 http://stackoverflow.com/a/24918964/939860 –
良い点@ErwinBrandstetterを参照してください、しかし、非常に簡単なアプリケーションであり、私は自分のデータベースに同時にアクセスするつもりはありません。 –