3
People help me with postgresql studies.How do you create a postgresql table? how do you use the alter table and drop table? and what differences of key Primary and key Foreign ?
3
People help me with postgresql studies.How do you create a postgresql table? how do you use the alter table and drop table? and what differences of key Primary and key Foreign ?
1
Create table:
CREATE TABLE tabela (
id INT NOT NULL,
nome VARCHAR(15),
data DATE,
PRIMARY KEY(id)
);
Delete table:
DROP TABLE tabela;
Change table (here it is a little abstract, would have to specify more):
ALTER TABLE tabela ACAO_QUE_VOCE_QUER_EXECUTAR;
Primary key: what defines the current element. Example: the primary key of your documents to the state is your CPF, while that of a company is the CNPJ.
Foreign key: used to define an external element. Example: the cab of the XXXX-YYY plate belongs to the citizen of CPF 123.456.789-01.
Tip: When asking a question in the community, try to be a little more specific, and you’ll get more accurate answers ;)
Browser other questions tagged database postgresql foreign-key primary-key
You are not signed in. Login or sign up in order to post.
The excellent Postgresql manual will be helpful: https://www.postgresql.org/docs/current/index.html
– anonimo