https://github.com/shiru99/cs313-dbms
Database Management System Lab Course (CS 313), IIT Dharwad
https://github.com/shiru99/cs313-dbms
dbms j2ee jdbc postgresql
Last synced: 6 days ago
JSON representation
Database Management System Lab Course (CS 313), IIT Dharwad
- Host: GitHub
- URL: https://github.com/shiru99/cs313-dbms
- Owner: Shiru99
- Created: 2021-06-14T08:10:40.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-04T04:15:03.000Z (almost 5 years ago)
- Last Synced: 2025-01-08T01:46:52.230Z (over 1 year ago)
- Topics: dbms, j2ee, jdbc, postgresql
- Language: HTML
- Homepage:
- Size: 27.2 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CS313 - DBMS Labs
## Installation
**How to Postgresql on Ubuntu**
***Postgresql Installation***
```
$ sudo apt-get update
$ sudo apt install postgresql postgresql-contrib
```
---
***Use Default User-psql***
```
$ sudo -u postgres psql postgres
```
---
***Use New User***
```
$ sudo -u postgres psql postgres
postgres=# CREATE ROLE universitydb0015 WITH PASSWORD '123';
postgres=# ALTER ROLE "universitydb0015" WITH LOGIN;
// for existing university db
$ psql -U universitydb0015 -h localhost -p 5432 -d university;
(Add tables through sql file)
university=> \i /home/"username"/Downloads/DDL.sql
```
---
# Postgresql
***list of databases***
```
university=> \l
```
***create database***
```
university=> CREATE DATABASE dbname;
```
***drop databases***
```
university=> DROP DATABASE dbname;
```
***to connect databases***
```
university=> \c university;
```
---
***list of tables***
```
university=> \dt
```
***create table***
```
university=> CREATE TABLE table_name(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL
);
```
***drop table***
```
university=> DROP TABLE table_name;
```
***info related table***
```
university=> \d student;
OR
university=> SELECT
table_name,
column_name,
data_type
FROM
information_schema.columns
WHERE
table_name = 'student';
```
---