-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDatabase information
33 lines (26 loc) · 1.92 KB
/
Database information
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
database: StudyGroup
current tables: UserInfo(Username, Pass, Email, Status), Groups(Gpassword, user, userlist, clock, message, moderator)
-> FriendListTest(username), AccountRecovery(email, question, username, QAnswer)
[quick database howtos]
SHOW databases; - to see all databases
USE [name]; - to select a database
SELECT [what] FROM [table name]; - query
select * from [table name] where [column name] like '%[what you're looking for]%'; - searches a column in a table. returns anything similar to whats inbetween the % similar to whats between the %
ALTER TABLE [table name] MODIFY [column name] [variable]; - for changing table inputs
ALTER TABLE [table name] ADD [column name] [variable] - for adding a column to a table
ALTER TABLE [table name] DROP COLUMN [column name]; - for deleting a column
ALTER TABLE table1 RENAME table2; - for renaming tables
CREATE DATABASE [database name]; - for creating a database
CREATE TABLE [table name] ([[id name] [variable]]*); - for creating a table
DROP TABLE [table name]; - for deleting a table
INSERT INTO accounts (username, pass, email) VALUES ('[name goes here]', '[password goes here]', '[email goes here]');
[potential friendlist integration code]
CREATE TABLE [username goes here]_FriendList (username varchar(20))
[upon adding a new friend]
ALTER TABLE [username goes here]_FriendList ADD COLUMN friend[last column +1] AFTER [last column name goes here];
[upon removing a friend]
- search table Friendlist columns for the name, alter table to remove that column
[potential group integration code]
CREATE TABLE Group_[incremental #] (CreatorName varchar(50), GroupName varchar(50), userList varchar(20), user varchar(20), Clock time, Message varchar (255));
Searching Databse for Table name
select table_name from information_schema.tables where TABLE_SCHEMA='$DB_Name' and table_name =%groupname%