Demo project
Published: 2024-07-12 01:30:46

```
CREATE USER hccdp WITH SYSADMIN PASSWORD 'Sadece1234';

CREATE DATABASE hccdp_db;

ALTER DATABASE hccdp_db OWNER TO hccdp;

```

```
gsql -d postgres -p 5432 -U root -W

```

```
CREATE USER hccdp WITH SYSADMIN PASSWORD 'Sadece1234';

```

```
CREATE DATABASE hccdp_db;

```

```
ALTER DATABASE hccdp_db OWNER TO hccdp;

```











```
gsql -d postgres -p 5432 -U root -W

```

```
CREATE DATABASE hccdp_db;
CREATE USER hccdp WITH SYSADMIN PASSWORD '<your_password>';
ALTER DATABASE hccdp_db OWNER TO hccdp;

```

```
\l

```

```
gsql -d hccdp_db -p 5432 -U hccdp -W

```

```
CREATE TABLE example_table (
    id SERIAL PRIMARY KEY,
    name VARCHAR(100),
    age INT
);

```

```
INSERT INTO example_table (name, age) VALUES ('John Doe', 30);

```

```
SELECT * FROM example_table;

```


```
ssh root@*EIP*
```

```
wget https://sandbox-expriment-files.obs.cn-north-1.myhuaweicloud.com:443/20220525/GaussDB_opengauss_client_tools.zip

```

```
unzip GaussDB_opengauss_client_tools.zip

```

```
cd GaussDB_opengauss_client_tools/Euler2.8_arm_64/

```

```
tar -xvf GaussDB-Kernel-V500R001C20-EULER-64bit-gsql.tar.gz

```

```
source gsql_env.sh

```
GaussDB veritabanına bağlanmak için gsql kullanın. Komutta -h, GaussDB veritabanının dağıtıldığı ECS'nin özel IP adresini belirtir, -d veritabanı adını belirtir, -U kullanıcı adını belirtir, -p bağlantı noktasını belirtir ve -W parolayı belirtir.

```
gsql -h *Private IP address* -U root -d postgres -p 8000 -W yourpassword -r

```

```
\q
```

```
gsql --help
```

```
\copyright

```

```
\h

```

```
\help CREATE DATABASE
```

```
\?
```

```
gsql -h *Private IP address* -U root -d postgres -p 8000 -W yourpassword -l

```


```
gsql -V
```

```
gsql -h *Private IP address* -U root -d postgres -p 8000 -W yourpassword -q

```

```
create table t_test (firstcol int);

```

```
insert into t_test values(200);

```

```
select * from t_test;

```

```
\q
```

```
gsql -h *Private IP address* -U root -d postgres -p 8000 -W yourpassword -S

```

```
select * from t_test;

```

```
select * from t_test
```

```
\q
```

```
gsql -h *Private IP address* -U root -d postgres -p 8000 -W yourpassword -r

```

```
select * from t_test;
```


Terminali açın ve aşağıdaki komutu kullanarak ECS'ye bağlanın:

```
ssh username@ecs-ip-address

```

```
wget https://example.com/path/to/GaussDB_opengauss_client_tools.zip
unzip GaussDB_opengauss_client_tools.zip -d /path/to/destination

cd /path/to/destination/EulerOS_X86_64

```

```
cd /path/to/destination/EulerOS_X86_64
./gsql -d hccdp_db -h 192.168.0.183 -p 8000 -U hccdp

```

```
systemctl status gaussdb

```

```
systemctl start gaussdb

```

gsql İstemci Araçlarını Ayıklama ve Çalıştırma

```
wget https://example.com/path/to/GaussDB_opengauss_client_tools.zip
unzip GaussDB_opengauss_client_tools.zip -d /path/to/destination
cd /path/to/destination/EulerOS_X86_64
./gsql -d hccdp_db -h 192.168.0.183 -p 8000 -U hccdp

```

gsql istemcisinin bulunduğu dizine geçin. 

```
cd /path/to/GaussDB_opengauss_client_tools/EulerOS_X86_64

```
GaussDB'ye bağlanın

```
./gsql -h 192.168.0.183 -U root -d postgres -p 8000 -W yourpassword -r

```
Burada 192.168.0.183 GaussDB'nin IP adresi, root kullanıcı adı, postgres veritabanı adı, 8000 port numarası ve yourpassword şifrenizdir.


Aşağıdaki komutu kullanarak GaussDB'ye bağlanın:

```
./gsql -d hccdp_db -h 192.168.0.183 -p 8000 -U hccdp

```
Burada hccdp_db veritabanı adı, 192.168.0.183 GaussDB'nin IP adresi, 8000 port numarası ve hccdp kullanıcı adıdır.o

```
CREATE SCHEMA hccdp;
CREATE TABLE hccdp.nation (
  N_NATIONKEY INT PRIMARY KEY,
  N_NAME VARCHAR(25),
  N_REGIONKEY INT,
  N_COMMENT VARCHAR(152)
);

```

```
\copy hccdp.nation FROM '/path/to/nation.csv' WITH (FORMAT csv, HEADER true);
\copy hccdp.part FROM '/path/to/part.csv' WITH (FORMAT csv, HEADER true);
\copy hccdp.supplier FROM '/path/to/supplier.csv' WITH (FORMAT csv, HEADER true);
\copy hccdp.partsupp FROM '/path/to/partsupp.csv' WITH (FORMAT csv, HEADER true);
\copy hccdp.orders FROM '/path/to/orders.csv' WITH (FORMAT csv, HEADER true);
\copy hccdp.lineitem FROM '/path/to/lineitem.csv' WITH (FORMAT csv, HEADER true);

```
Veri sorgulama işlemi için örnek bir SQL komutu:

```
SELECT * FROM hccdp.nation;

```
Stored procedure oluşturma:

```
CREATE OR REPLACE PROCEDURE proc_nation() AS $$
BEGIN
  -- Buraya prosedür içeriği gelecek
END;
$$ LANGUAGE plpgsql;

```